poj 1742 coins_多重背包
来源:互联网 发布:简单制图软件 编辑:程序博客网 时间:2024/05/23 21:26
题意:给你N个种硬币,价值和数量,知道手表不大于m,问能组成(1~m)的价格有多少种情况
套套上次那题的模板直接就行了,http://blog.csdn.net/neng18/article/details/17060539
#include <iostream>#include<cstring>#include<cstdio>using namespace std;#define MAXV 150#define MAXM 100050int cash,n,value[MAXV],c[MAXV],f[MAXM],user[MAXM];int main(){int i,j,max;while(scanf("%d%d",&n,&cash)&&n||cash){for(i=1;i<=n;i++)scanf("%d",&value[i]);for(i=1;i<=n;i++)scanf("%d",&c[i]);memset(f,0,sizeof(f));f[0]=1;max=0;for(i=1;i<=n;i++){memset(user,0,sizeof(user));for(j=value[i];j<=cash;j++)if(!f[j] && f[j-value[i]] && user[j-value[i]]+1<=c[i]){user[j]=user[j-value[i]]+1;f[j]=1;//j为1,即j是可取的,选出可取的最大的j就是答案max++;}}printf("%d\n",max);}return 0;}
- poj 1742 coins_多重背包
- POJ 1742 多重背包
- poj 1742 多重背包
- poj 1742多重背包
- poj 1742 多重背包
- poj 1742(多重背包)
- POJ 1742 多重背包
- POJ 1742 多重背包问题
- poj 1742 Coins(多重背包)
- poj 1742 多重背包可行性
- poj 1742 Coins(多重背包)
- POJ-1742(多重背包)
- POJ-1742-多重背包-Coins
- POJ 1742 Coins (多重背包)
- POJ 1742多重背包问题
- poj 1742 多重背包入门
- Poj 1742 Coins【多重背包】
- poj 1742 多重背包,可行性
- NSObject的常用方法
- NYOJ-264-国王的魔镜-2013年10月23日22:11:54
- LeetCode Palindrome Number
- sdut-2725-The Urge to Merge-状压DP
- 笔试题二:冒泡排序算法实现
- poj 1742 coins_多重背包
- 第十四周自由练习项目——随意输入数从大到小输出
- 递归算法-汉诺塔问题
- Java编码建议-1
- 数据结构课程设计(约瑟夫环)
- 笔试题三:带头节点head链表逆序
- 将win7电脑无线网变身WiFi热点,让手机、笔记本共享上网
- linux zip/unzip命令
- NYOJ-275-队花的烦恼一-2013年10月23日22:51:57