zoukankan      html  css  js  c++  java
  • 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 }
  • 相关阅读:
    机器学习 深度学习 网站
    Concat层解析
    网络可视化工具netron详细安装流程
    【中文】【deplearning.ai】【吴恩达课后作业目录】
    python 3 linux环境搭建django production环境
    eCharts画图
    mysql 外键
    django执行离线ORM、数据操作
    http 发包调试工具
    python有空仔细研究
  • 原文地址:https://www.cnblogs.com/pshw/p/5173191.html
Copyright © 2011-2022 走看看