## 10872 - Triangles

Moderator: Board moderators

TISARKER
Learning poster
Posts: 88
Joined: Tue Oct 12, 2004 6:45 pm
Contact:

### Re: 10872(How Many Triangles?)WA

Is there any tricky input.Please give me.
Mr. Arithmetic logic Unit

mf
Guru
Posts: 1244
Joined: Mon Feb 28, 2005 4:51 am
Location: Zürich, Switzerland
Contact:
Try these test cases

Code: Select all

``````1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
1000000000
2000000000
2147483643
2147483644
2147483645
2147483646
2147483647
0
``````
Output:

Code: Select all

``````Case 1: 0
Case 2: 0
Case 3: 1
Case 4: 0
Case 5: 1
Case 6: 1
Case 7: 2
Case 8: 1
Case 9: 3
Case 10: 2
Case 11: 4
Case 12: 3
Case 13: 5
Case 14: 4
Case 15: 7
Case 16: 20833333333333333
Case 17: 83333333333333333
Case 18: 96076791871613611
Case 19: 96076791692656640
Case 20: 96076792050570581
Case 21: 96076791871613611
Case 22: 96076792229527552``````

TISARKER
Learning poster
Posts: 88
Joined: Tue Oct 12, 2004 6:45 pm
Contact:
Thx mf.Finally I got Accepted.
I found my error only for sample input 4.
My output was 1 rather 0.
Actually 4 is an ecceptional and critical input.
Mr. Arithmetic logic Unit

Antonio Ocampo
Experienced poster
Posts: 131
Joined: Sat Jul 17, 2004 4:09 am
Location: Lima, Per
I got AC, thx anyway. By the way, it was a rounding error.

mysword
New poster
Posts: 26
Joined: Sun Mar 06, 2005 8:52 am

### 10872

can anyone give some input-ouput data? thx

don't know why WA.....

StatujaLeha
Learning poster
Posts: 91
Joined: Tue May 31, 2005 2:01 pm
Location: Russia
Input:
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
43562456
6776
57745
7457567
568
657884
457375674
5685684
4735673
67896789
2356
67568584
45747
768976
23647
65856884
45764575
562456436
999980
999981
999982
999983
999984
999985
999986
999987
999988
999989
999990
999991
999992
999993
999994
999995
999996
999997
999998
999999
1000000
0
Output:
Case 1: 1
Case 2: 1
Case 3: 2
Case 4: 1
Case 5: 3
Case 6: 2
Case 7: 4
Case 8: 3
Case 9: 5
Case 10: 4
Case 11: 7
Case 12: 5
Case 13: 8
Case 14: 7
Case 15: 10
Case 16: 8
Case 17: 39535157765665
Case 18: 956545
Case 19: 69475656
Case 20: 1158653131352
Case 21: 6721
Case 22: 9016903280
Case 23: 4358177232644881
Case 24: 673479219747
Case 25: 467221399520
Case 26: 96041132581068
Case 27: 115640
Case 28: 95114865495105
Case 29: 43605469
Case 30: 12319251845
Case 31: 11652552
Case 32: 90356857712280
Case 33: 43633262489960
Case 34: 6590775883287960
Case 35: 20832500008
Case 36: 20832666672
Case 37: 20832583340
Case 38: 20832750004
Case 39: 20832666672
Case 40: 20832833336
Case 41: 20832750004
Case 42: 20832916669
Case 43: 20832833336
Case 44: 20833000001
Case 45: 20832916669
Case 46: 20833083334
Case 47: 20833000001
Case 48: 20833166667
Case 49: 20833083334
Case 50: 20833250000
Case 51: 20833166667
Case 52: 20833333333
Case 53: 20833250000
Case 54: 20833416667
Case 55: 20833333333
Last edited by StatujaLeha on Sun Dec 11, 2005 10:17 pm, edited 1 time in total.

Martin Macko
A great helper
Posts: 481
Joined: Sun Jun 19, 2005 1:18 am
Location: European Union (Slovak Republic)
StatujaLeha wrote:Input:
...
42764573683
568696595895
...
45756784568
...
45758678976
...
The 23rd, 24th, 27th and 36th case is invalid becouse its correct answer doesn't fit in a 64-bit integer. Their posted answers are incorrect as you've probably got an overflow. All others answers are correct.

StatujaLeha
Learning poster
Posts: 91
Joined: Tue May 31, 2005 2:01 pm
Location: Russia
Martin Macko wrote:
StatujaLeha wrote:Input:
...
42764573683
568696595895
...
45756784568
...
45758678976
...
The 23rd, 24th, 27th and 36th case is invalid becouse its correct answer doesn't fit in a 64-bit integer. Their posted answers are incorrect as you've probably got an overflow. All others answers are correct.
thank you, i have fixed it.

abhiramn
New poster
Posts: 29
Joined: Sat May 26, 2007 7:54 pm

Code: Select all

``````Code Accepted.
You do not have to use and floating point numbers. Once you do that, you will get accepted. Thanks a ton Mr. Jan.
``````
I am getting WA. I have tried the code for all sample inputs in the forum. It works perfectly. God knows what is happening. Please help me..
Last edited by abhiramn on Tue Jun 05, 2007 5:01 am, edited 1 time in total.

Jan
Guru
Posts: 1334
Joined: Wed Jun 22, 2005 10:58 pm
Contact:
'long double' is too risky for this problem. Try the cases. In my compiler your code returns wrong answers.

Input:

Code: Select all

``````2147483646
2147483645
2147483644
2147483643
2147483642
0``````
Output:

Code: Select all

``````Case 1: 96076791871613611
Case 2: 96076792050570581
Case 3: 96076791692656640
Case 4: 96076791871613611
Case 5: 96076791513699670``````
Hope these help.
Ami ekhono shopno dekhi...
HomePage