[GESP202609 六级] 分树规划
该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。
Problem Description
A teacher has a tree with nodes, numbered in order.
The teacher wants to give this tree as a prize to two students. Specifically, the teacher will choose one edge and delete it from the tree, thereby splitting the tree into two connected components. Each student will receive one of the connected components.
If one student gets a component whose number of nodes is obviously smaller than the other student's, that student may feel unhappy. To avoid this, the teacher wants to know what the minimum possible absolute difference between the sizes (number of nodes) of the two components is.
Input Format
The first line contains a positive integer , representing the number of nodes.
The next lines each contain two positive integers , representing an edge connecting nodes and .
Output Format
Output one line with one integer, representing the answer.
4
1 2
2 3
3 4
0
6
1 2
1 3
1 4
1 5
5 6
2
Hint
For of the testdata, it is guaranteed that .
For all testdata, it is guaranteed that .
Translated by ChatGPT 5