The One Where They Get Back Together
F.R.I.E.N.D.S stars Jennifer Aniston, Courteney Cox, Lisa Kudrow, Matt LeBlanc, Matthew Perry and David Schwimmer have come together for the much-awaited reunion. The whole cast is going to shoot for the episode on the sets of their show. Being a huge fan, Chef's family is excited to watch the live shoot.
The set has infinite rows with infinite seats in each row for the audience. The seats are numbered starting from as shown in the image above. Let the seat number of the seat in the row and column be . The price of a seat is equal to the seat number of that particular seat.
Chef wants to reserve exactly seats for his family members such that the reserved seats form a rectangle and all the family members stay together.
Chef is allowed to choose a reduction price . After choosing the value of reduction price; if Chef has chosen the seat in the row and column, the price of this seat becomes for Chef. The total price of the seats selected by Chef is equal to the sum of individual prices of seats (after applying the reduction price).
Find the minimum possible total price Chef will have to pay for a selection of seats which form a rectangle of area exactly . Since this number can be huge, print it modulo ().
Input Format
- First line will contain , number of testcases. Then the testcases follow.
- Each testcase contains of a single line of input, one integer , denoting the number of people in Chef's family.
Output Format
For each testcase, output in a single line the minimum price Chef has to pay for reserving seats modulo ().
Constraints
Sample Input 1
3
1
4
2021
Sample Output 1
0
5
1364637
Explanation
Test case 1: One of the possible optimal selections would be seat number and = . Cost equals |seat number - X|, i.e. .
Test case 2: Chef needs seats. Some possible selections are shown through rectangles in red, purple and green.
- Seats coloured in purple: . If Chef chooses = , Cost is | - | + | - | + | - | + | - | = . For = , Cost is | - | + | - | + | - | + | - | = .
- Seats coloured in red: . If Chef chooses = , Cost is | - | + | - | + | - | + | - | = . For = , Cost is | - | + | - | + | - | + | - | = . We can calculate the cost for other values of similarly.
In this case, one of the optimal selections would be seats coloured in red, with = .
Comments
Post a Comment