Squares in a grid square
Time limit2sMemory limit512 MB
For each grid side length l, count every square whose sides lie along grid lines, including tilted ones.
- Level
Easy3 of 10
- Topics
- Math, Combinatorics, Implementation
- Solved
- No attempts yet
Problem
The game "La cave aux énigmes" asks how many squares are contained in a grid square whose side has length . A grid square of side length 4 looks like this.

Thirty squares are visible in that picture. Count every square visible in the picture of a grid square of side length .
Input
The first line contains the number of test cases . ()
Each of the next lines contains one side length of a grid square. ()
Output
For each , print the number of squares visible in the picture of a grid square of side length , one per line. The answer can exceed the range of a 32-bit integer, so use 64-bit integers.