zoukankan      html  css  js  c++  java
  • BNUOJ 17286 Dollars

    Dollars

    Time Limit: 3000ms
    Memory Limit: 131072KB
    This problem will be judged on UVA. Original ID: 147
    64-bit integer IO format: %lld      Java class name: Main
     

    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_inline25 10c, 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


    解题:几个坑。一是要用long long ,而是要输入0 终止程序

     1 #include <iostream>
     2 #include <cstdio>
     3 #include <cstring>
     4 #include <cmath>
     5 #include <algorithm>
     6 #include <climits>
     7 #include <vector>
     8 #include <queue>
     9 #include <cstdlib>
    10 #include <string>
    11 #include <set>
    12 #include <stack>
    13 #define LL long long
    14 #define pii pair<int,int>
    15 #define INF 0x3f3f3f3f
    16 using namespace std;
    17 int c[] = {5,10,20,50,100,200,500,1000,2000,5000,10000};
    18 LL dp[30010];
    19 int main() {
    20     int val = 30000;
    21     double ans;
    22     memset(dp,0,sizeof(dp));
    23     dp[0] = 1;
    24     for(int i = 0; i < 11; i++){
    25             for(int j = c[i]; j <= val; j++){
    26                 dp[j] += dp[j-c[i]];
    27             }
    28         }
    29     while(~scanf("%lf",&ans) && ans != 0.00 ){
    30         printf("%6.2f%17lld
    ",ans,dp[int(ans*100+0.5)]);
    31     }
    32     return 0;
    33 }
    View Code
  • 相关阅读:
    高并发系统设计(十九)【注册中心】:微服务架构结合RPC框架如何做到分布式系统寻址?
    高并发系统设计(十八):【RPC框架】10万QPS下如何实现毫秒级的服务调用?
    you-get 库的使用方法
    vue 全局注册signalr
    将Minio.exe注册成windows服务
    NPOI 常用方法封装
    利用NPOI给excel文件中添加图片
    Oss 对象服务存储前端方法封装
    C# 常用方法扩展及封装记录
    PostgreSQL配置密码复杂度策略
  • 原文地址:https://www.cnblogs.com/crackpotisback/p/3915790.html
Copyright © 2011-2022 走看看