I’ve been trying to solve this simple dp problem but I’m getting WA. I can’t find anything wrong with my code. Can anybody please help me out?

Problem - http://www.codechef.com/problems/COINS

my submission - http://www.codechef.com/viewsolution/3277375

You use “long int” which is just a 32 bit signed integer on most systems.

Going through the accepted solutions it seems the solution doesn’t fit in a “long int” always. Use either a “unsigned long int” or “long long int” most accepted solutions in C/C++ use one of these.

1 Like

Thanks vaka. That did it. :slight_smile: