Time Limit: 1000MS | Memory Limit: 10000K | |
Total Submissions: 24213 | Accepted: 8476 |
Description
N=3, n1=10, D1=100, n2=4, D2=50, n3=5, D3=10
means the machine has a supply of 10 bills of @100 each, 4 bills of @50 each, and 5 bills of @10 each.
Call cash the requested amount of cash the machine should deliver and write a program that computes the maximum amount of cash less than or equal to cash that can be effectively delivered according to the available bill supply of the machine.
Notes:
@ is the symbol of the currency delivered by the machine. For instance, @ may stand for dollar, euro, pound etc.
Input
cash N n1 D1 n2 D2 ... nN DN
where 0 <= cash <= 100000 is the amount of cash requested, 0 <=N <= 10 is the number of bill denominations and 0 <= nk <= 1000 is the number of available bills for the Dk denomination, 1 <= Dk <= 1000, k=1,N. White spaces can occur freely between the numbers in the input. The input data are correct.
Output
Sample Input
Sample Output
735
630
0
0
Hint
In the second case the bill supply of the machine does not fit the exact amount of cash requested. The maximum cash that can be delivered is @630. Notice that there can be several possibilities to combine the bills in the machine for matching the delivered cash.
In the third case the machine is empty and no cash is delivered. In the fourth case the amount of cash requested is @0 and, therefore, the machine delivers no cash.
Source
都没用多重背包,随便写了个DP+二进制优化。。。。
#include <iostream>
#include <cstdio> #include <cstring> using namespace std; bool money[110000]; int main() return 0; |
* This source code was highlighted by YcdoiT. ( style: Codeblocks )
POJ 1276 Cash Machine的更多相关文章
-
Poj 1276 Cash Machine 多重背包
Cash Machine Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 26172 Accepted: 9238 Des ...
-
poj 1276 Cash Machine(多重背包)
Cash Machine Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 33444 Accepted: 12106 De ...
-
POJ 1276 Cash Machine(单调队列优化多重背包)
Cash Machine Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 38986 Accepted: 14186 De ...
-
POJ 1276 Cash Machine -- 动态规划(背包问题)
题目地址:http://poj.org/problem?id=1276 Description A Bank plans to install a machine for cash withdrawa ...
-
【转载】poj 1276 Cash Machine 【凑钱数的问题】【枚举思路 或者 多重背包解决】
转载地址:http://m.blog.csdn.net/blog/u010489766/9229011 题目链接:http://poj.org/problem?id=1276 题意:机器里面共有n种面 ...
-
POJ 1276 Cash Machine(多重背包的二进制优化)
题目网址:http://poj.org/problem?id=1276 思路: 很明显是多重背包,把总金额看作是背包的容量. 刚开始是想把单个金额当做一个物品,用三层循环来 转换成01背包来做.T了… ...
-
[poj 1276] Cash Machine 多重背包及优化
Description A Bank plans to install a machine for cash withdrawal. The machine is able to deliver ap ...
-
POJ 1276 Cash Machine(完全背包模板题)
Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 44409 Accepted: 16184 Description A B ...
-
POJ 1276 Cash Machine 【DP】
多重背包的模型,但一开始直接将N个物品一个一个拆,拆成01背包竟然T了!!好吧OI过后多久没看过背包问题了,翻出背包九讲看下才发现还有二进制优化一说........就是将n个物品拆成系数:1,2,4, ...
随机推荐
-
java 深入技术六(Map)
Map 1.map概述 map.put(key,value)里面存放的是两个相关的数据,key=value键值对 Map集合中存放的是键值对(put(key,value)),用get(key)获取集合 ...
-
dedecms文章标题是在哪个数据库表?要批量替换关键词
一位小MM刚接触dedecms没多久还不熟悉后台的操作,她说改dedecms文章中的品牌名改到手酸,问ytkah是否有批量替换关键词的方法,教了她dedecms后台批量替换文章中的关键词方法,她高兴坏 ...
-
Eclipse启动Tomcat访问不了首页
Eclipse开发web项目与myEclipse不同: 启动服务器后访问 http:localhost:8080 找不到服务器 想要访问Tomcat首页只需修改Tomcat配置 进入Eclipse双击 ...
-
Tomcat Server 原理
构成: 1.server代表整个catalina serverlet容器 2.service:由一个或多个connector以及一个共享的engine处理引擎组成 3.connector 在指定端口上 ...
-
python udp编程实例
与python tcp编程控制见 http://blog.csdn.net/aspnet_lyc/article/details/39854569 c++ udp/tcp 编程见 http://blo ...
-
PHP 接口 返回构造函数
我们写接口的时候,需要返回json数据,并且里面有错误码,错误信息 还有要返回的数据,这里我构造了一个函数 这里是针对TP5来写的,自己可以根据自己的框架来修改 这样就可以在返回的时候直接用info函 ...
-
Linux2.6内核--抢占
[摘要]本文首先介绍非抢占式内核(Non-Preemptive Kernel)和可抢占式内核(Preemptive Kernel)的区别.接着分析Linux下有两种抢占:用户态抢占(User Pree ...
-
Tornado的安装使用
https://blog.csdn.net/a312024054/article/details/52207367 tornado原理: tornado的使用 import tornado.ioloo ...
-
QT4编程过程中遇到的问题及解决办法
1.QLineEdit显示内容的格式函数: QLineEdit *lineEditPassword = new QLineEdit: lineEditPassword -> setEchoMod ...
-
mysql source 执行sql脚本,中文变量不显示问题或乱码问题
执行脚本内容如下: SET @pre_version=2017080901; SET @cur_version=2017090401; SET @ver_desc = '测试脚本'; CALL pro ...