Network Investment
InterviewTime limit1sMemory limit128 MB
Find the tree edge whose removal maximizes the product of the two component sizes.
Problem
The computer network of Byteland consists of nodes connected by fiber-optic links. The fiber network is not dense: between any two nodes there is exactly one path (possibly passing through intermediate nodes), so the network forms a single tree. Because of this, some links carry heavy traffic and cause large delays in transmitting information.
The traffic in the network is quite heavy and evenly spread. That is, in every unit of time every pair of nodes exchanges exactly one packet of information with each other. The load of a link is the number of packets that pass through that link in one unit of time. (If a link is removed the network splits into two parts, and the load of that link equals the number of nodes on one side multiplied by the number of nodes on the other side.)
The company managing the network wants to know whether the load is large enough that the network needs to be upgraded or expanded. To decide this, it needs to know the load of the most heavily loaded link.
Write a program that computes the load of the most heavily loaded link in the network.
Input
The first line contains the number of nodes (). The nodes are numbered from to . Each of the next lines describes one link, one per line. Each line contains two integers separated by a space, giving the numbers of the two nodes connected by that link.
Output
Output a single integer: the load of the most heavily loaded link in the network.