#P6277. [USACO20OPEN] Circus P
[USACO20OPEN] Circus P
Description
The cows in Farmer John's circus are preparing for an upcoming show. The entire show takes place on a tree with nodes numbered . An "initial state" of the show is defined by an integer (), where cows are placed on nodes of the tree, and no two cows are on the same node.
During a show, the cows may "move" any number of times. In one "move", a cow can move from its current node to an unoccupied adjacent node. If one state can be reached from another through a sequence of moves, then we say these two initial states are equivalent.
For each , you need to help the cows determine how many equivalence classes of initial states there are. In other words, find the maximum number of initial states such that they are pairwise not equivalent. Since the number may be large, output the answer .
Input Format
The first line contains an integer .
The next lines each contain two integers , indicating that there is an edge in the tree connecting and .
Output Format
Output a total of lines. For each , on line output the answer for , taken .
5
1 2
2 3
3 4
3 5
1
1
3
24
120
8
1 3
2 3
3 4
4 5
5 6
6 7
6 8
1
1
1
6
30
180
5040
40320
Hint
Explanation of Sample :
For and , any two states can be reached from each other.
Now consider . Let denote the position of cow . Then the state is equivalent to the states and , but it is not equivalent to the state .
For of the testdata, it is guaranteed that .
There are test points. Among them, are the samples, and the remaining points have the following properties:
For test points , .
For test points , .
For test points , , and the tree is a "star": at most one node has degree greater than .
For test points , .
For test points , there are no special restrictions.
Problem setter: Dhruv Rohatgi
Translated by ChatGPT 5
京公网安备 11011102002149号