UVA-147
Dollars
Time Limit: 3000MS |
|
Memory Limit: Unknown |
|
64bit IO Format: %lld &%llu |
Submit Status
Description
New Zealand currency consists of $, $, $ $, $ $, $ notes and $ $, $50c, 20c, 10c and 5c coins. Write a program that would determine, for any given amount, in how many ways that amount may is made up. Changing the order of listing does not increase the count. Thus 20c May is made up in 4 ways:1 20c, 2 10c, 10c+2 5c, and 4 5c.
Input
Input would consist of a series of real numbers no greater than $300.00 each on a separate line. Each amount would be valid, which is would be a multiple of 5c. The file is terminated by a line containing zero (0.00).
Output
Output would consist of a line for each of the amounts in the input, each line consisting of the amount of Decimal places and right justified in a field of width 6), followed by the number of ways in which that amount could be made Up, right justified in a field of width 17.
Sample Input
0.202.000.00
Sample Output
0.20 4 2.00 293
Source
Root:: Competitive programming:increasing The Lower Bound of programming contests (Steven & Felix Halim):: Chapter 3. Problem solving Paradigms:: Dynamic Programming:: Coin change-classical
Root:: AOAPC i:beginning algorithm Contests (Rujia Liu):: Volume 5. Dynamic programming
Root:: Competitive programming 2:this increases the lower bound of programming contests. Again (Steven & Felix Halim):: Problem Solving Paradigms:: Dynamic Programming:: Coin change (CC)
Root:: Competitive programming 3:the New Lower Bound of programming contests (Steven & Felix Halim):: Problem Solvi Ng Paradigms:: Dynamic Programming:: Coin change (CC)
Submit Status
Idea: Simple dynamic programming problems, because each face value is an integer multiple of 5cent, so all denominations are converted to multiples of 5cent, i.e. {1, 2, 4, 10, 20, 40, 100, 200, 400, 1000, 2000};
The number entered is also converted to a multiple of 5, paying attention to the floating point problem
Then DP preprocessing, output remember the width of the field to follow the requirements, here DP because it will explode int, to open to LL type
AC Code:
Uva-147-dollars (Dynamic planning on a collection)