博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
poj1742 多重背包的可行性问题
阅读量:7034 次
发布时间:2019-06-28

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

id=1742

Description

People in Silverland use coins.They have coins of value A1,A2,A3...An Silverland dollar.One day Tony opened his money-box and found there were some coins.He decided to buy a very nice watch in a nearby shop. He wanted to pay the exact price(without change) and he known the price would not more than m.But he didn't know the exact price of the watch. 
You are to write a program which reads n,m,A1,A2,A3...An and C1,C2,C3...Cn corresponding to the number of Tony's coins of value A1,A2,A3...An then calculate how many prices(form 1 to m) Tony can pay use these coins. 

Input

The input contains several test cases. The first line of each test case contains two integers n(1<=n<=100),m(m<=100000).The second line contains 2n integers, denoting A1,A2,A3...An,C1,C2,C3...Cn (1<=Ai<=100000,1<=Ci<=1000). The last test case is followed by two zeros.

Output

For each test case output the answer on a single line.

Sample Input

3 101 2 4 2 1 12 51 4 2 10 0

Sample Output

84
/**poj 1742  多重背包的可行性问题题目大意:给定n种面值的硬币面值分别为wi个数为ci。问用这些硬币能够组成1~m之间的多少面值解题思路:楼教主的男人八题之中的一个。算是一个经典的问题,定义一个sum数组。每次填dp[j]时直接由dp[j-weight[i]]推出。          前提是sum[j-w[i]]
#include
#include
#include
using namespace std;int n,m;int w[105],c[105],sum[100005],dp[100005];int main(){ while(~scanf("%d%d",&n,&m)) { if(n==0&&m==0)break; for(int i=0;i

转载地址:http://eznal.baihongyu.com/

你可能感兴趣的文章
py 的 第 29 天
查看>>
c#之循环效率
查看>>
hdu1176免费馅饼
查看>>
《面向对象程序设计课程学习进度条》
查看>>
[转]nginx反向代理获取用户真实ip
查看>>
外边距合并与溢出
查看>>
单例模式的C++实现
查看>>
memory_profiler的使用
查看>>
Vue过渡动画运用transition
查看>>
AIDL示例
查看>>
HTML字符实体
查看>>
ubuntu 清理系统垃圾与备份
查看>>
Css3笔记
查看>>
springboot之定时任务
查看>>
c++配置文件.ini,GetPrivateProfileString( )\WritePrivateProfileString( )
查看>>
11、创建Huffman树,生成Huffman编码
查看>>
Between Us 2 进化的史诗
查看>>
BZOJ 1019: [SHOI2008]汉诺塔
查看>>
flash模拟苹果菜单原理
查看>>
Redis入门到高可用(二十一)——缓存的使用和设计
查看>>