From http://blog.csdn.net/shuangde800
Link: poj-1947
Question
To a tree, ask at least a few sides to delete, so that the number of nodes in the remaining subtree is P.
Ideas
I read this question a few days ago, but I have no idea. I think about it every day. Today, I still have doubts about my methods.
In the case of, even ac ..
F (I, j) indicates subtree I, which retains the minimum number of edge deletions for J nodes. Note that the subtree OF THE J nodes is the root node.
Subtree with J nodes for I. In this way, it is easy to think about state transfer.
For subtree I, if only one node is retained, the edge connecting all its son nodes must be deleted,
Therefore, you can initialize f (I, 1) = node I's son count.
F (I, j), that is, the subtree I retains J nodes, so for each subtree of I, you can choose to retain 1, 2,... J-1 nodes
Then each subtree can be considered as a group of items, and all the subtree is grouped into a backpack.
If the sub-tree v chooses to retain K points, then the sub-tree I will retain J-K points.
So transition from status:
F (I, j) = max {f (I, j-k) + f (v, k) -1 | 1 <= k <s} | V is the son node of I}
Eventually ans = min {f (I, p) | 1 <= I <= n}
Code