随笔分类 -  背包问题

摘要://背包问题:f[v]=max(f[v],f[v-cost]+weight)#include<iostream>#define max(a,b) a>b?a:busing namespace std;int c[300000],i,k,sum,a[110],b[110],n;//01背包void bag(int cost,int weight){for(i=sum/2;i>=cost;i--)c[i]=max(c[i],c[i-cost]+weight);}//完全背包void complete(int cost,int weight){for(i=cost;i< 阅读全文
posted @ 2012-07-27 15:44 疼痛落在指尖 阅读(160) 评论(0) 推荐(0) 编辑