uva147Dollars(完全背包)
发布日期:2022-02-02 02:58:10 浏览次数:20 分类:技术文章

本文共 1506 字,大约阅读时间需要 5 分钟。

New Zealand currency consists of $100, $50, $20, $10, and $5notes and $2, $1, 50c, 20c, 10c and 5c coins. Write a program thatwill determine, for any given amount, in how many ways that amount maybe 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 will consist of a series of real numbers no greater than $300.00each on a separate line. Each amount will be valid, that is will be amultiple of 5c. The file will be terminated by a line containing zero(0.00).

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 placesand right justified in a field of width 6), followed by the number ofways in which that amount may be made up, right justified in a fieldof width 17

0.202.000.00

0.20                4  2.00              293

题目大意:

给定11种面值分别为$100, $50, $20, $10, and $5 notes and $2, $1, 50c, 20c, 10c and 5c coins的钱,现在给定一个钱数,求出可以组成的种类数。

代码实现:

#include 
#include
#include
#define MAX 999999using namespace std;long long dp[MAX];int n,arr[20]={5,10,20,50,100,200,500,1000,2000,5000,10000};int main(){ int i,j,k; double t; while(cin>>t) { if(t==0.00)break; n=(t+0.005)*100; memset(dp,0,sizeof(dp)); dp[0]=1; for (i = 0; i <= 10; i++) for (j = 0; j <= n; j++) dp[j+arr[i]] += dp[j]; cout<
<
<
<<" "<
<

转载地址:https://blog.csdn.net/u010368749/article/details/19898169 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:uva10465Homer Simposon(完全背包)
下一篇:hdu1171---Big Event in HDU(多重背包)

发表评论

最新留言

表示我来过!
[***.240.166.169]2024年03月08日 04时23分27秒

关于作者

    喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!

推荐文章

linux 8086下编译,Ubuntu18.04/Linux下安装DosBox进行8086汇编 2019-04-21
linux监控windows,zabbix监控之linux及windows客户端安装配置 2019-04-21
linux中怎么卸载tree,Liunx系统命令中tree命令详解 2019-04-21
linux 网络音箱 混音6,Linux音频编程(三)混音器介绍 2019-04-21
node与mysql开源_node与mysql的相互使用————node+mysql 2019-04-21
python合并列表重新排序_python – 将两个已排序的列表合并为一个更大的排序列表... 2019-04-21
vbs用mysql语句查询数据库_vbs脚本实现window环境下的mysql数据库的备份及删除早期备份... 2019-04-21
mysql连接nginx_nginx四层负载均衡连接mysql 2019-04-21
mysql截取栏目字符_substring从指定字符串开始截取(图) 2019-04-21
python 函数参数前面两个星号_Python中参数前面一个星号两个星号(*参数,**参数)起什么作用呢?... 2019-04-21
python类属性初始化_Python类定义、属性、初始化和析构 2019-04-21
mysql构建url给scrapy_Python Scrapy从mysq填充起始url 2019-04-21
owdcloud mysql_MySQL在Ubuntu远程配置 2019-04-21
python基础装饰器_Python基础 装饰器及练习 2019-04-21
python导出csv不带引号的句子_不带双引号写入CSV文件 2019-04-21
python爬虫代码模板_Python:学习Python爬虫的第一天 2019-04-21
springboot获取原生js请求_springboot跳转原生html 2019-04-21
java buffer nio_Java NIO之Buffer(缓冲区)入门 2019-04-21
android java加密_android 和java平台通用的AES加密解密 2019-04-21
java导出类_java导出excel工具类 2019-04-21