Intense love for mathematics
Practice
2.8 (8 votes)
Ad Hoc
Mathematics
Medium
Open
Approved
Mathamatics
Problem
44% Success 482 Attempts 30 Points 5s Time Limit 256MB Memory 1024 KB Max Code

Dexter loves to solve problems. This time his friend Ashish decides to challenge him.
Ashish gives him number N, all the numbers from 1 to N can be arranged in a 2-D matrix. There can be multiple arrangements such that the value of a palpak is maximized.
What is palpak?
Suppose the matrix made by arranging the numbers is A
A new matrix is made from A (say B) whose values are calculated as:
Let the number of rows be N
Let the number of columns be M

for i from 1 to N  
      for j from 1 to M  
            B[i][j]=A[i][j]  
            for k from i+1 to N  
                  B[i][j]=B[i][j]%A[k][j]

palpak is the value calculated from the matrix B as follows:

palpak=1 
for i from 1 to N
      sum=0
      for j from 1 to M
            sum=sum+B[i][j]
            palpak=palpak*sum

Dexter is trying hard to solve this problem. Please help Dexter in solving this problem.

Input Format
The first line contains T, the number of test cases.
Then N numbers follow.

Output Format
Output the query of Dexter mod 1000000007.

Constraints
1 <= T <= 10
1 <= N <= 1000

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:30
3 votes
Tags:
C++Basic MathObservationMath
Points:30
4 votes
Tags:
MathematicsMediumOpenApprovedMathamatics
Points:30
Tags:
Medium