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
#include <stdio.h> #include <string.h> #include <stdlib.h> #include <math.h> #include < ctype.h> #include <iostream> #include <string> #include <algorithm>using namespace Std;long long a[ 6001]; Record the number of combinations of each kind of money int b[]={1,2,4,10,20,40,100,200,400,1000,2000};int main () {for (int i=0; i<=6000; i++) a[i]=1;// Only 5 points for (int i=1; i<11; i++)//starting from subscript 1, 0 subscript has been skipped {for (int j=b[i]; j<=6000; j + +)//enumeration can use Class I currency each possible {A[j]=a[j]+a[j-b [i]]; The current number of Species + the number of methods of the former i-1 currency composition J-b[i]}}double dd;while (scanf ("%lf", &dd)!=eof) {if (dd==0.00) break;int n= (int) (dd*20.0); printf ("%6.2lf%17lld\n", DD, A[n]);} return 0;}
UVA 147 Dollars