UVA 147 Dollars
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
The main topic: Give a sum of money, ask 11 denominations of currency, there are several forms. problem-solving ideas: Pay attention to the issue of the amount of money to deal with, as well as the output of the norms to see.
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <algorithm>using namespace Std;int Coin[11] = {10000,----------------- (scanf ("%d.%d", &a, &b) = = 2) {if (a = = 0 && b = = 0) Break;int n = a * + b;memset (DP, 0, sizeof (DP));DP [0] = 1;for (int i = ten; I >= 0; i --) {for (int j = coin[i]; j <= N; j + +) {if (Dp[j-coin[i]]) {Dp[j] + = Dp[j-coin[i]];}} printf ("%3d.%.2d%17.lld\n", A, B, Dp[n]);} return 0;}
UVA 147 Dollars (DP)