All Submissions


Lets come to question directly.
In a 2D array of size n*n, first x natural numbers are written in a spiral form (as shown in figure).
Find sum of all the numbers which appears in its diagonals.

17 16 15 14 13
18 5 4 3 12
19 6 1 2 11
20 7 8 9 10
21 22 23 24 25

P.S: n is always odd

Input:
First line of input contains an integer t:: number of test cases.
each test case contains an integer n, which is the size of spiral matrix (Size of above matrix is 5).

Output:
For each test case output an integer which is sum of all the numbers appearing in its diagonals.

Constraints :
1<=t<=10^6
1<=n<=10^6

Sample input

1
5

Sample Output

101

Problem Setter: Sumit Kumar

Languages: AWK,Bash,Brain,C,C++,Java,C#,JavaScript,Pascal,Perl,PHP,Python,Python3,Ruby,Text

Time Limit: 1 Second(s)
Score: 100 Point(s)
Input File Limit: 50000 Bytes

Submit

Login to post clarification.

No Clarifications.

Contest

Mode Judge

Passive

Online

Overall Rankings

RankNameScore
1xyz0
2Ams0
3TIP0
4team420
5xyzz0
6asdasdasd0
7abcd0
8khankhan0
9Gabriel0
10gigel0