TRICOUNT  Counting Triangles
We define the LEVEL of a triangle as in the following illustrative image:
Task: Your task is very easy. All you have to do is to count all triangles in the biggest one (Level N).
Input
The first line of the input contains an integer T (T ≤ 10000)  the number of test cases and T lines follow. Each line contains an integer N (1 ≤ N ≤ 10^{6}) which is the level of the triangle in that test case.
Output
For each test case, you should write a seperate line: the number of triangles in the biggest one (Level N). (All answers will fit within the range of a 64bit integer)
Example
Input:
3
1
2
3
Output:
1
5
13
Source limit is 500 bytes.
hide comments
knakul853:
20181101 11:13:34
just find formula : ) 

masterchef2209:
20181018 14:52:35
costed too many WAs :( 

rohitjain00:
20180927 16:14:29
Java Users use Buffered Reader Instead of Scanner 

bloodgreed99:
20180830 16:10:59
cout<<pow(2,n+1)3<<endl; 

deceptiveuser1:
20180824 12:36:25
for the intuition of the formula: https://www.youtube.com/watch?v=9EU3FlKj3M Last edit: 20180824 12:36:46 

m2do:
20180630 19:29:36
What is the pattern here? missing 3rd level figure makes it hard to understand it. Can anybody explain the pattern? 

thisistia:
20180622 17:53:46
Is using the formula necessary? I wrote the program using functions separately for upwards and downwards(oddeven), and it's working fine.. But the file size is exceeding 500B, in C++. How to fix this? Last edit: 20180811 17:11:23 

milw0rm_007:
20180621 07:12:30
For those who are getting TLE in java, use Bufferreader instead of scanner ;)


ashutoshiiita:
20180603 00:18:03
shubham31 ...you missed those inverted triangles add them and get AC :) 

spartan09:
20180601 17:16:24
I am using this recurrence relation but it is giving TLE

Added by:  nha.duong 
Date:  20070805 
Time limit:  0.237s 
Source limit:  500B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All except: ASM64 ERL JSRHINO NODEJS OBJC PERL6 SQLITE VB.NET 
Resource:  Trần Huy Hưng 