The cows have set up a telephone network, which for the purposes of this problem can be considered to be an unrooted tree of unspecified degree with N (1 <= N <= 100,000) vertices conveniently numbered 1..N. Each vertex represents a telephone switchboard, and each edge represents a telephone wire between two switchboards. Edge i is specified by two integers and
the are the two vertices joined by edge i (1 <=
<= N; 1 <=
<= N;
!=
).
Some switchboards have only one telephone wire connecting them to another switchboard; these are the leaves of the tree, each of which is a telephone booth located in a cow field.
For two cows to communicate, their conversation passes along the unique shortest path between the two vertices where the cows are located. A switchboard can accomodate only up to K (1 <= K <= 10) simultaneous conversations, and there can be at most one conversation going through a given wire at any one time.
Given that there is a cow at each leaf of the tree, what is the maximum number of pairs of cows that can simultaneously hold conversations? A cow can, of course, participate in at most one conversation.
1 5 C1 C5 | | || || 2---4 --> |2---4| | | || || 3 6 C3 C6
* Line 1: Two space separated integers: N and K
* Lines 2..N: Line i+1 contains two space-separated integers:and
* Line 1: The number of pairs of cows that can simultaneously hold conversations