Search found 5 matches

by huan086
Wed Dec 20, 2006 5:02 pm
Forum: Volume 1 (100-199)
Topic: 108 - Maximum Sum
Replies: 233
Views: 21825

b[j]=b[i-1][j]+b[j-1]-b[i-1][j-1]+a[j];

You accessed b[0] without initialising the array... :( I believe you need to do so in c++. (not needed in VB though)

Search through the forum and see how others had done it. Your code is longer than the typical ones.

And debug before posting 8)
by huan086
Wed Dec 20, 2006 12:12 pm
Forum: Volume 1 (100-199)
Topic: 104 - Arbitrage
Replies: 223
Views: 13120

1 more test case here in case you made the same logic error as me Input: 20 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1.00049764032455 1.00049764032455 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1.00049764032455 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1.00049764032455 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1.0004...
by huan086
Wed Dec 20, 2006 11:13 am
Forum: Volume 1 (100-199)
Topic: 104 - Arbitrage
Replies: 223
Views: 13120

never mind. found my logic error. I have been overwriting values i still need in the next iteration, which had cause my program to miss out arbitrage sequence like 1 4 3 2 1.

Thanks to all who had tried to debug
by huan086
Wed Dec 20, 2006 6:18 am
Forum: Volume 1 (100-199)
Topic: 108 - Maximum Sum
Replies: 233
Views: 21825

I believe this line is wrong

temp=b[j]-b[k];
if(s>max) max=s;

i think you mean s=b...
by huan086
Tue Dec 19, 2006 5:14 pm
Forum: Volume 1 (100-199)
Topic: 104 - Arbitrage
Replies: 223
Views: 13120

Don't get what's wrong

Is there something wrong with my method? I try to maximise the conversion from i to j at every step, then check the diagonal values in the table. my output is this 10 16 10 16 10 1 2 1 1 2 4 1 no arbitrage sequence exists 5 6 5 no arbitrage sequence exists 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 1...

Go to advanced search