#C8002. Counting Squares in a Grid

    ID: 51937 Type: Default 1000ms 256MiB

Counting Squares in a Grid

Counting Squares in a Grid

In this problem, you are given an integer (N) representing the size of a square grid (i.e., an (N \times N) grid). Your task is to compute the total number of squares that can be formed in the grid. A square can have various sizes, and a square of size (k \times k) can be placed in any position where it fits in the grid. The total number of squares is given by the formula:

[ \text{Total Squares} = \sum_{i=1}^{N} i^2 = 1^2 + 2^2 + \cdots + N^2 ]

For example, if (N=2), the answer is (1^2 + 2^2 = 1+4=5). Your solution should read the input from stdin and output the result for each test case to stdout.

inputFormat

The first line of input contains a single integer (T), denoting the number of test cases. Each of the following (T) lines contains a single integer (N) representing the size of the grid.

outputFormat

For each test case, output a single line containing the total number of squares that can be formed in an (N \times N) grid.## sample

3
1
2
3
1

5 14

</p>