[luoguP2015] 二叉苹果树(DP)


传送门

貌似是个树形背包。。。

好像吧。。

f[i][j]表示节点i选条边的最优解

#include <cstdio> #include <cstring> #include <iostream> #define N 101 #define max(x, y) ((x) > (y) ? (x) : (y)) int n, q, cnt; int head[N], to[N << 1], next[N << 1], val[N << 1], f[N][N]; bool vis[N]; inline int read() inline void add(int x, int y, int z) inline void dfs(int u) } } int main() dfs(1); printf("%d\n", f[1][q]); return 0; }

  



上一篇:[luoguP1013] 进制位(搜索)

下一篇:[luoguP1489] 猫狗大战(DP)


DP
Copyright © 2002-2019 k262电脑网 www.k262.cn 皖ICP备2020016292号
温馨提示:部分文章图片数据来源与网络,仅供参考!版权归原作者所有,如有侵权请联系删除!QQ:251442993 热门搜索 网站地图