CF BUDDY
← Problems·

1829G · Hits Different

1600 · data structures, dp, implementation

Problem: In a carnival game, there is a huge pyramid of cans with 20232023 rows, numbered in a regular pattern as shown.

If can 929^2 is hit initially, then all cans colored red in the picture above would fall.

You throw a ball at the pyramid, and it hits a single can with number n2n^2. This causes all cans that are stacked on top of this can to fall (that is, can n2n^2 falls, then the cans directly above n2n^2 fall, then the cans directly above those cans, and so on). For example, the picture above shows the cans that would fall if can 929^2 is hit.

What is the sum of the numbers on all cans that fall? Recall that n2=n×nn^2 = n \times n.

Input Format: The first line contains an integer tt (1t10001 \leq t \leq 1000) — the number of test cases.

The only line of each test case contains a single integer nn (1n1061 \leq n \leq 10^6) — it means that the can you hit has label n2n^2.

Output Format: For each test case, output a single integer — the sum of the numbers on all cans that fall.

Please note, that the answer for some test cases won't fit into 32-bit integer type, so you should use at least 64-bit integer type in your programming language (like long long for C++). For all valid inputs, the answer will always fit into 64-bit integer type.

Note: The first test case is pictured in the statement. The sum of the numbers that fall is 12+22+32+52+62+92=1+4+9+25+36+81=156.1^2 + 2^2 + 3^2 + 5^2 + 6^2 + 9^2 = 1 + 4 + 9 + 25 + 36 + 81 = 156.

In the second test case, only the can labeled 121^2 falls, so the answer is 12=11^2=1.

In the third test case, the cans labeled 121^2 and 222^2 fall, so the answer is 12+22=1+4=51^2+2^2=1+4=5.

In the fourth test case, the cans labeled 121^2 and 323^2 fall, so the answer is 12+32=1+9=101^2+3^2=1+9=10.

In the fifth test case, the cans labeled 121^2, 222^2, and 424^2 fall, so the answer is 12+22+42=1+4+16=211^2+2^2+4^2=1+4+16=21.

Sample Cases

Case 1

Input

10
9
1
2
3
4
5
6
10
1434
1000000

Output

156
1
5
10
21
39
46
146
63145186
58116199242129511

Similar problems

00:00:00
Loading editor…
Welcome! I'm your coding tutor for this problem. Use the chips below to reveal stored hints or get AI feedback on your code. I'll guide you step by step — never giving away the solution.

Sign in to unlock AI tutor feedback