find the bug?
![:)](./images/smilies/icon_smile.gif)
I'm pretty sure my algorithm is correct. however, what's the output
for n=0 supposed to be? (i tried 0 and 1, but got WA both times.
![:(](./images/smilies/icon_frown.gif)
Thanks for any help.
Moderator: Board moderators
Code: Select all
100 10 10
100
200
200 30 75
200 111 199
300
299 88 1000
47 7 709
Code: Select all
2977866
190569292
3972999029388
1147203119198
409038375
9253082936723602
122368041480637
117650
Code: Select all
0
0 0
0 1
0 0 0
0 0 1
0 1 1
0 1 2
200 30 75
Code: Select all
1
1
1
1
1
0
0
2347163627458
If your algorithm is really O(n^3) then you must be doing something inefficiently, because 300^3 is only 27 million, which should easily run in way less than 30s if each of the 27m operations are simple enough.Revenger wrote:I just wonder how the program can work less than 2 seconds. My program work 29.530 seconds and get Accepted. But I have no idea how to optimaze it. Can anyone give me a hint to make a good fast program?
P.S. I use DP. My algorithm is O(n^3). May be exist a algorithm O(n^2 (log n))?
Joe Smith wrote: But, you can solve it in O(n^2)... you only need to fill a 300x300 array, where A[j] is the # of ways of getting $i total dollars where all the coins are of value at most j.