J-dollars
Time limit:3000 Ms
Memory limit:0 KB
64bit Io format:% LLD & % llusubmitstatus
Description
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 4 2.00 293 simple DP. Note that the double type cannot be forcibly converted. Note that the data input has the following features: use an integer to read data. AC code:# Include <iostream> # include <cstdio> using namespace STD; long DP [33000]; int A [15] = {5, 10, 20, 50, 100,200,500,100 }; int main () {// freopen ("in.txt", "r", stdin); // double S, N; DP [0] = 1; for (INT I = 0; I <11; I ++) for (Int J = 5; j <= 30000; j + = 5) if (j> = A [I]) DP [J] + = DP [J-A [I]; int A, B; while (~ Scanf ("% d. % d ", & A, & B) // you cannot use double to read {long x = A * 100 + B; If (x = 0) break; printf ("% 6.2lf % 17lld \ n", (double) x/100.0, DP [x]);} return 0 ;}
Dollars (simple DP)