• uva 147 Dollars


     Dollars 

    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 tex2html_wrap_inline25 20c, 2 tex2html_wrap_inline2510c, 10c+2 tex2html_wrap_inline25 5c, and 4 tex2html_wrap_inline25 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.20
    2.00
    0.00

    Sample output

      0.20                4
      2.00              293

    和上一道模板题差不多,因为有小数,但是最多两位小数,所以所有数据直接变成20倍计算。注意输出格式。

    题意:11种钱币,指定钱的数额,输出最大组成数。

    附上代码:

     1 #include <iostream>
     2 #include <cstdio>
     3 #include <cstring>
     4 using namespace std;
     5 long long dp[6005];
     6 int main()
     7 {
     8     int i,j,m;
     9     int coin[11]= {1,2,4,10,20,40,100,200,400,1000,2000};
    10     memset(dp,0,sizeof(dp));
    11     dp[0]=1;
    12     for(i=0; i<11; i++)
    13         for(j=coin[i]; j<=6000; j++)
    14             dp[j]+=dp[j-coin[i]];
    15     double n;
    16     while(~scanf("%lf",&n))
    17     {
    18         m=(int)(n*20);
    19         if(m==0) break;
    20         printf("%6.2lf%17lld
    ",n,dp[m]);
    21     }
    22     return 0;
    23 }
  • 相关阅读:
    ISAPI_Rewrite应用技巧与方法
    Linux下MONO执行C#程序
    正则表达式与 re 模块[转]
    网页自适应不同浏览器和分辨率[转]
    DIV 元素 | div 对象(4)
    自适应浏览器分辨率的javascript函数[转]
    常用正规表达式
    div置顶且屏蔽底下图层的图层
    IIS连接数
    什么是RIA?
  • 原文地址:https://www.cnblogs.com/pshw/p/5173191.html
Copyright © 2020-2023  润新知