UVa 147 - Dollars

147 - Dollars

 * http://acm.uva.es/p/v1/147.html

Summary
Count the number of ways we can form a certain amount.

Explanation
This is a standard Dynamic Programming problem. The recurrence is simply: $$f( x ) = \Sigma_{i = 1\ldots N} f( x - a_i )$$ where $$a = ( 5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000 )$$.

Optimizations

 * You can make the array smaller by noting that everything is a multiple of 5 cents.

Input
0.20 2.00 0.00

Output
0.20               4  2.00              293