#P1842F. Tenzing and Tree
Tenzing and Tree
Description
Tenzing has an undirected tree of vertices.
Define the value of a tree with black and white vertices in the following way. The value of an edge is the absolute difference between the number of black nodes in the two components of the tree after deleting the edge. The value of the tree is the sum of values over all edges.
For all such that , Tenzing wants to know the maximum value of the tree when vertices are painted black and vertices are painted white.
The first line of the input contains a single integer () — the number of vertices.
The following lines of the input contains integers and () — indicating an edge between vertices and . It is guaranteed that the given edges form a tree.
Output numbers. The -th number is the answer of .
Input
The first line of the input contains a single integer () — the number of vertices.
The following lines of the input contains integers and () — indicating an edge between vertices and . It is guaranteed that the given edges form a tree.
Output
Output numbers. The -th number is the answer of .
Note
Consider the first example. When , Tenzing can paint vertices and black then the value of edge is 0, and the values of other edges are all equal to . So the value of that tree is .