随笔分类 - 背包问题
摘要://背包问题: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<
阅读全文