摘要: 有依赖的背包,转化成01背包来做;#include#include#include#includeusing namespace std;int n,m;int f[100009];int dp[100009];int main(){ int num,value,pen,pp; while(scanf("%d%d",&n,&m)!=EOF) { memset(f,0,sizeof f); for(int i=1; i=pen; j--) { dp[j]=max(dp[j],dp[j... 阅读全文
posted @ 2014-04-08 15:37 Yours1103 阅读(124) 评论(0) 推荐(0) 编辑
摘要: 有依赖的背包,用树形dp解#include#include#include#include#define maxn 205using namespace std;int n,m;int f[maxn][maxn];struct node{ int pre; int cnt_son; int son[maxn]; int value;} no[maxn];void dfs(int x){ f[x][1]=no[x].value; int v; for(int i=0; i1; j--)//从大往小更新,结果不会覆盖; { ... 阅读全文
posted @ 2014-04-08 14:13 Yours1103 阅读(109) 评论(0) 推荐(0) 编辑