2013年3月26日

多重背包POJ1276不要求恰好装满 poj1014多重背包恰好装满

摘要: 二进制压缩,看背包九讲啦,写的很详细了,不赘述````先贴不要求恰好装满的情形POJ 1276二进制压缩: 1 #include <cstdio> 2 #include <cstring> 3 int f[100005];//容量为i时最多能装多少 4 int p[12000];//物品拆分 5 int main() 6 { 7 int n,cash; 8 while(~scanf("%d%d",&cash,&n)) 9 {10 int vi,num;//物品价值,数量11 int cur = 0;12 memset(f,... 阅读全文

posted @ 2013-03-26 20:10 allh123 阅读(232) 评论(0) 推荐(0) 编辑

哈理工1053完全背包

摘要: 顺序求解是完全背包,逆序求解是0-1背包,自己想想View Code 1 #include <cstdio> 2 #include <cstring> 3 using namespace std; 4 struct node 5 { 6 int cost,value; 7 } ; 8 node u[100005]; 9 int f[100005];10 int main()11 {12 int G,U;13 int T,cur;14 scanf("%d",&T);15 while(T--)16 {17 // freopen("in. 阅读全文

posted @ 2013-03-26 20:06 allh123 阅读(127) 评论(0) 推荐(0) 编辑

导航