Skip to content

Commit 9850c5e

Browse files
committed
SPOJ Added Tricount
1 parent e396361 commit 9850c5e

File tree

4 files changed

+41
-0
lines changed

4 files changed

+41
-0
lines changed
1.17 KB
Loading
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
Input
3+
4+
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 = 106) which is the level of the triangle in that test case.
5+
Output
6+
7+
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 64-bit integer)
8+
Example
9+
10+
Input:
11+
3
12+
1
13+
2
14+
3
15+
16+
Output:
17+
1
18+
5
19+
13
20+
21+
22+
ALGORITHM:
23+
24+
1. (input*(input+2)*(2*input+1))/8
25+
*/
26+
27+
# include <iostream>
28+
typedef long long llong;
29+
using namespace std;
30+
int main()
31+
{
32+
int size;
33+
llong input;
34+
cin>>size;
35+
while(size--)
36+
{
37+
cin>>input;
38+
cout<<((input*(input+2)*(2*input+1))/8)<<endl;
39+
}
40+
}
41+
4.61 KB
Loading
1.75 KB
Loading

0 commit comments

Comments
 (0)