POJ 1276 : Cash Machine - 多重背包
来源:互联网 发布:淘宝买家秀福利的店铺 编辑:程序博客网 时间:2024/06/06 00:14
最基础的多重背包
#include<iostream>#include<cstdio>#include<cstring>using namespace std;const int N=100005;int cash,k,n[N],w[N],c[N],dp[N],cnt[N]; //cnt[]限制取bills的个数int main(){int i,j;while(~scanf("%d%d",&cash,&k)){for(i=0;i<k;i++){scanf("%d%d",&n[i],&w[i]);c[i]=w[i];//此处体积c[i]与价值w[i]相同}memset(dp,0,sizeof(dp));for(i=0;i<k;i++){memset(cnt,0,sizeof(cnt));for(j=w[i];j<=cash;j++){if(dp[j]<dp[j-c[i]]+w[i] && cnt[j-c[i]]<n[i]){dp[j]=dp[j-c[i]]+w[i];cnt[j]=cnt[j-c[i]]+1;}}}printf("%d\n",dp[cash]);}return 0;}
0 0
- POJ 1276 Cash Machine(多重背包)
- poj 1276 Cash Machine(多重背包+倍增)
- poj 1276 Cash Machine(多重背包)
- POJ 1276 Cash Machine (多重背包)
- poj 1276 Cash Machine (多重背包)
- poj 1276 Cash Machine----多重背包
- POJ 1276 Cash Machine (多重背包)
- POJ 1276 Cash Machine 多重背包
- 多重背包 poj 1276 Cash Machine
- 【POJ】1276 Cash Machine(多重背包)
- 【DP|多重背包】POJ-1276 Cash Machine
- poj 1276 Cash Machine(多重背包)
- POJ 1276 Cash Machine【多重背包DP】
- poj 1276 Cash Machine (多重背包)
- POJ 1276 Cash Machine(多重背包)
- poj 1276 Cash Machine(多重背包)
- poj 1276 Cash Machine (多重背包)
- poj 1276 Cash Machine (多重背包)
- POJ 2714 : Random Walk - 贪心
- POJ 3177 / POJ 3352 : Redundant Paths / Road Construction - 边双连通分量,缩点
- #include<list>类的用法
- js DateFormat
- 带分数 - 搜索,next_permutaion妙用
- POJ 1276 : Cash Machine - 多重背包
- POJ 3176 : Triangle - 水DP
- POJ 2533 : Longest Ordered Subsequence - LIS问题
- POJ 1631 : Bridging signals - 最长上升子序列 O(nlog n)
- ZOJ 3770 : Ranking System (第14届浙江大学程序设计竞赛 D) - 结构体排序,vector
- POJ 1966 / ZOJ 2182 : Cable TV Network - 顶点连通度
- POJ 1062 : 昂贵的聘礼 - 最短路Dijkstra+枚举(难)
- POJ 1988 : Cube Stacking - 简单并查集
- POJ 1060/ ZOJ 1026 : Modular Multiplication of Polynomials - f(x)g(x) mod h(x)