Can anybody help me with this one , I tested it on numerous testcases , it works but for no reason it fails on some.
Here's the code
Code: Select all
#include <iostream>
using namespace std;
int main()
{
int coins[]={1,5,10,25,50};
int all[10000],n;
for(int i=0;i<10000;i++)all[i]=0;
all[0]=1;
all[1]=1;
for(int i=0;i<5;i++)
{
for(int j=1;j<8000;j++)
{
all[j+coins[i]]+=all[j];
}
}
while(scanf("%d",&n)==1)
{
printf("%d\n",all[n]);
}
}
The input:
Code: Select all
0
57
129
134
239
277
300
386
393
455
510
535
568
610
637
642
790
1426
1446
1498
1503
1590
1600
1624
1635
1647
1691
1722
1931
2116
2261
2455
2547
2663
2703
2707
2765
2827
2915
3258
3349
3915
3960
4261
4691
4800
4862
4928
5001
5151
5246
5331
5376
5559
5826
5853
5975
6071
6168
6239
6321
6423
6482
6543
6620
6796
6962
6973
7026
7104
7355
7414
7481
7489
My output: // note that only the bolded output is wrong
Code: Select all
1
62
558
628
4160
7098
[b]9044[/b]
23124
24216
[b]40570[/b]
[b]61787
73788[/b]
93418
120380
144144
148421
319464
3131855
3305565
3771460
3820626
4732112
4849152
5151289
5276018
5467319
6072570
6503070
10190440
14574076
18894799
25930850
30107714
35816715
37980910
38258165
41409284
45379809
50994880
79289342
88293002
163511040
171076240
229494139
335794790
366569984
386652189
407548350
432699251
486474872
523030235
557449884
576345348
656770352
792830259
806417782
874084640
933653312
993015250
1038534000
1095890112
1166373065
1210262495
1255379026
1313534866
1461345024
1607484130
1616679680
1667962743
1739848682
1996345212
2061906700
2140421225
2146113925
The expected output according to a post on the first page:
Code: Select all
1
62
558
628
4160
7098
9590
23124
24216
42230
64064
76384
93418
124124
144144
148421
327216
3131855
3305565
3771460
3820626
4790368
4908497
5151289
5339224
5467319
6072570
6503070
10190440
14574076
18894799
26139150
30107714
35816715
37980910
38258165
41705076
45379809
51340620
79289342
88293002
164338960
171932760
229494139
335794790
368086385
386652189
407548350
432699251
486474872
523030235
557449884
576345348
656770352
792830259
806417782
876993480
933653312
993015250
1038534000
1095890112
1166373065
1210262495
1255379026
1317482439
1461345024
1607484130
1616679680
1667962743
1739848682
2001748100
2061906700
2140421225
2146113925