You are given a positive integer N. Your task is to find the number of possible rectangles, excluding squares, in a N x N chessboard.
Example:Let’s assume that we have a chessboard of dimension 4x4, i.e. N = 4. Then the rectangles can have the following possible dimensions: {1*2, 1*3, 1*4, 2*1, ……, 2*4, ………,4*4}. So, the total number of rectangles in the chessboard is 70.
The very first line of input contains an integer T’ denoting the number of test cases.
The first line of every test case contains an integer ‘N’ denoting the dimension of the chessboard.
Output format:
For each test case, print the number of possible rectangles, excluding squares, in a N x N chessboard.
Output for each test case is printed on a separate line.
Note:
The result can be very large. So, print the answer modulo 1000000007.
You do not need to print anything, it has already been taken care of. Just return the number of possible rectangles.
1 <= T <= 10
1 <= N <= 5 * 10^4
Time Limit: 1 sec
2
4
1
70
0
For the first test case refer to the example explained above.
For the second test case we have, a chessboard of dimension 1x1, i.e. N = 1. There are no possible rectangles. Hence, the answer is zero.
2
2
5
4
170
Try finding total possible rectangles, including squares. Then subtract the number of possible squares.
O(1)
Only constant time is required for calculating the number of possible rectangles. Hence, the time complexity is O(1).
O(1)
Only constant extra space is required for calculating the number of possible rectangles. Hence, the space complexity is O(1).