New Zealand currency consists of $100, $50, $20, $10, and $5 notes and $2, $1, 50C, 20C, 10c and 5C coins. write a program that will determine, for any given amount, in how many ways that amount may be made up. changing the order of listing does not increase the count. thus 20c may be made up in 4 ways: 1 20C, 2 10C, 10C + 2 5C, and 4 5C.
Input
Input will consist of a series of real numbers no greater than $300.00 each on a separate line. each amount will be valid, that is will be a multiple of 5C. the file will be terminated by a line containing zero (0.00 ).
Output
Output will consist of a line for each of the amounts in the input, each line consisting of the amount of money (with two decimal places and right justified in a field of width 6 ), followed by the number of ways in which that amount may be made up, right justified in a field of width 17.
Sample Input
0.202.000.00
Sample output
0.20 42.00 293
Question: for a classic question, change the money.
Precision. The table playing speed may be faster ..
# Include <iostream> # include <cstdio> # include <cstring> # include <algorithm> # include <limits. h> typedef unsigned long ll; using namespace STD; # define repf (I, a, B) for (INT I = A; I <= B; ++ I) # define rep (I, n) for (INT I = 0; I <n; ++ I) # define clear (A, x) memset (A, X, sizeof) int A [] = {5, 10, 20, 50, 100,200,500,100, 300100,}; ll DP []; int N; int main () {Double X; while (~ Scanf ("% lf", & X) & X! = 0) {n = (INT) (x * 100 + 0.5); // + 0.5 pay attention to precision // cout <"23333" <n <Endl; memset (DP, 0, sizeof (DP); DP [0] = 1; rep (I, 11) // Add each currency to J {repf (J, a [I], n) DP [J] + = DP [J-A [I];} printf ("% 6.2f % 17lld \ n", X, DP [N]);}
Va 147 dollars (DP)