#P17458. [GESP202609 六级] 分树规划
[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