POJ 1276 Cash Machine(完全背包模板题)
| Time Limit: 1000MS | Memory Limit: 10000K | |
| Total Submissions: 44409 | Accepted: 16184 |
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
Hint
The first data set designates a transaction where the amount of cash requested is @735. The machine contains 3 bill denominations: 4 bills of @125, 6 bills of @5, and 3 bills of @350. The machine can deliver the exact amount of requested cash.
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.
AC代码
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(多重背包的二进制优化)
题目网址: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(单调队列优化多重背包)
Cash Machine Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 38986 Accepted: 14186 De ...
- 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: 24213 Accepted: 8476 Descrip ...
- POJ 3624 Charm Bracelet(01背包模板题)
题目链接 Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 52318 Accepted: 21912 Descriptio ...
- 【转载】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 Description A Bank plans to install a machine for cash withdrawa ...
随机推荐
- JAVA操作InfluxDB的一个Demo
一.基础连接类 package com.test.repository.utils; import com.dcits.domain.entry.bo.common.InfluxDbRow; impo ...
- 如何在Mac下配置多个Java版本
使用工具:brew cask brew cask是一个用命令行管理Mac下应用的工具,提供了自动安装和卸载功能,能够自动从官网上下载并安装 最新的版本,它是基于homebrew的一个增强工具. 一. ...
- Hexo主题开发
序章 想要一个自己的知识管理系统,用了 Hexo ,但是没有发现自己心仪的主题,就自己做了一个.本文记录了制作的全过程.本人编码功底和前端知识并不是特别雄厚,希望能由此文引出各路大神的兴趣,以后制作出 ...
- 使用paginate方法分页无法判断获取的数据是否为空
问题:使用paginate方法分页无法判断获取的数据是否为空,在模板里面无法判断数据是否为空,比如在商品列表当中,当没有商品时无法判断生成的对象为空,所有就什么都不显示了. 解决办法: $newsDa ...
- windows server 2012配置php环境教程
买了windows系统的服务器(VPS)等之后我们需要一个php环境来搭建自己的项目,这里介绍手工在windows server 2012上面配置php环境的具体步骤,适合使用服务器和VPS等的新手. ...
- MySQL的rpm安装教程
Linux 上安装 MySQL Linux平台上推荐使用RPM包来安装Mysql,MySQL AB提供了以下RPM包的下载地址: MySQL - MySQL服务器.你需要该选项,除非你只想连接运行在另 ...
- 汉诺塔问题深度剖析(python实现)
当我们学习一门编程语言的时候,都会遇到递归函数这个问题.而学习递归的一个经典案例就是汉诺塔问题.通过这篇文章,观察移动三个盘子和四个盘子的详细过程,您不仅可以深刻的了解递归,也更加熟悉了汉诺塔的游戏的 ...
- webUploader大文件断点续传学习心得 多文件
二.Jsp代码: <!-- 断点续传 start--> <!-- 隐藏域 实时保存上传进度 --> <input id="jindutiao" t ...
- No qualifying bean of type 'com.chinanums.agent.operation.service.component.OperationPageComponent' available:
java.lang.IllegalStateException: Failed to load ApplicationContext at org.springframework.test.conte ...
- Android Studio + uiautomator 配置运行
1.在build.gradle中添加依赖: androidTestImplementation 'com.android.support.test.uiautomator:uiautomator-v1 ...