This solution is accepted: http://codeforces.net/contest/479/submission/8546349
However, if I change line 29 from
ps[j] = ps[j - 1] + dp[pidx][j];
to
ps[j] = (ps[j - 1] + dp[pidx][j]) % MOD;
The outputs of test 6 and many other test cases of my program are wrong. I have two questions:
- I think that the two versions are mathematically equivelent, aren't they?
- Why overflow error does not happen for the first version? Unsigned long long is really large enough?
Thanks for your help.