摘要: 简单的树形DP,状态转移方程如下:令res[i]表示以i为根的子树获得的最大值;第i个人去或者不去。去的话,res[i]=value[i]+∑res[j], j表示i的孩子的孩子;不去的话,res[i]=∑res[k],k表示i的孩子;因此,res[i]=max{value[i]+∑res[j],∑res[k]};代码如下:#include<iostream>#include<cstdio>#include<cstring>using namespace std;#define MAX 123456789struct node{ int i,next;}ve 阅读全文
posted @ 2012-04-08 10:38 书山有路,学海无涯 阅读(179) 评论(0) 推荐(0) 编辑