#x1077. You Are Given a Tree
You Are Given a Tree
You Are Given a Tree
题面翻译
有一棵 个节点的树。
其中一个简单路径的集合被称为 合法当且仅当:
树的每个节点至多属于其中一条路径,且每条路径恰好包含 个点。
对于 ,求出 合法路径集合的最多路径数 即:设 合法路径集合为 ,求最大的 。
。
题目描述
A tree is an undirected graph with exactly one simple path between each pair of vertices. We call a set of simple paths -valid if each vertex of the tree belongs to no more than one of these paths (including endpoints) and each path consists of exactly vertices.
You are given a tree with vertices. For each from to inclusive find what is the maximum possible size of a -valid set of simple paths.
输入格式
The first line of the input contains a single integer ( ) — the number of vertices in the tree.
Then following lines describe the tree, each of them contains two integers , ( ) — endpoints of the corresponding edge.
It is guaranteed, that the given graph is a tree.
输出格式
Output numbers, the -th of which is the maximum possible number of paths in an -valid set of paths.
样例 #1
样例输入 #1
7
1 2
2 3
3 4
4 5
5 6
6 7
样例输出 #1
7
3
2
1
1
1
1
样例 #2
样例输入 #2
6
1 2
2 3
2 4
1 5
5 6
样例输出 #2
6
2
2
1
1
0
提示
One way to achieve the optimal number of paths for the second sample is illustrated in the following picture: