poj 1742 coins 多重背包,只是用来标记可以组成多少个小于m的值
来源:互联网 发布:混合云 数据同步 编辑:程序博客网 时间:2024/05/01 18:22
#include<cstdio>#include<iostream>#include<cstring>#include<algorithm>using namespace std;int f[100009];int used[100009];int main(){ int n,m; int a[110]; int c[110]; while(cin>>n>>m,n+m){ for(int i=0;i<n;i++) cin>>a[i]; for(int i=0;i<n;i++) cin>>c[i]; memset(f,0,sizeof(f)); f[0]=1; int ans=0; for(int i=0;i<n;i++){ memset(used,0,sizeof(used));//若used[]数组再开大一位就会超时。 //为了记录每个包用过的次数,每个包都得初始化 for(int j=a[i];j<=m;j++) if(!f[j]&&f[j-a[i]]&&used[j-a[i]]+1<=c[i]){//used[]记录用过的次数 f[j]=1; ans++; used[j]=used[j-a[i]]+1; } } cout<<ans<<endl; }}
- poj 1742 coins 多重背包,只是用来标记可以组成多少个小于m的值
- poj 1742 Coins(多重背包)
- poj 1742 Coins(多重背包)
- POJ-1742-多重背包-Coins
- POJ 1742 Coins (多重背包)
- Poj 1742 Coins【多重背包】
- POJ 1742 Coins 多重背包
- POJ 1742 Coins(多重背包)
- poj 1742coins(优化的多重背包)
- POJ 1742 Coins (多重背包的两种解法)
- poj 1742 Coins(多重背包可行性问题)
- Poj 1742 Coins(多重背包)
- POJ 1742 Coins 多重背包入门题
- poj 1742 Coins 多重背包变形
- poj 1742 Coins (多重背包)
- 【DP|多重背包可行性】POJ-1742 Coins
- POJ 1742 Coins 多重背包题解
- POJ 1742 - Coins (dp 多重背包)
- JAVA Server上传文件 Spring MultipartResolver 或者 ServletFileUpload
- django中如何使用login_required来解决登陆的麻烦
- 堆变量和栈变量
- WHU 1462 - B – Books changing
- 用eclipse建一个web页面(图文)
- poj 1742 coins 多重背包,只是用来标记可以组成多少个小于m的值
- HDU 4478(Where is the King)
- [113]Path Sum II
- 比较字符串是否相等
- matlab图形句柄属性总结
- Opencv中将视频保存为连续的图片和连续的图片保存为视频
- 同步Google通讯录的新方法
- centos6.3 Geany 使用
- 可用性测试好助手——Morae软件的应用