Raghav and matrices

3.6

27 votes
Problem

Raghav is interested to play with matrices. In this matrix problem. Raghav has to count the total number of square and rectangle formed by the [n x n] matrix but he is unable to do so. Help Raghav to count the required numbers.

Input Format:
The first line contains the number of test cases, T. T lines follow, each of which contains number of rows or columns N.

Output Format:
Print the total number of squares and rectangles.

Constraints
1<=T<=1000
1<=N<=300

Sample Input
1
3
Sample Output
14
36
Time Limit: 2
Memory Limit: 256
Source Limit:
Explanation

Figure shows 3x3 matrix, contains 14 square matrix and 36 rectangles. In which the First line of output shows the total number of squares possible by making a matrix of 3x3.
enter image description here

Second line of output shows the total number of rectangles possible by making a matrix of 3x3.

Editor Image

?