403657: GYM101234 D Forest Game
Memory Limit:0 MB
Time Limit:4 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
D. Forest Gametime limit per test4 secondsmemory limit per test512 mebibytesinputstandard inputoutputstandard output
Consider the following boring game about removing nodes from a forest. Initially, the forest contains only one tree with N nodes, and your initial score is 0. The game then goes as follows:
- If the forest is empty, the game is finished. Otherwise, you choose one node from the current forest uniformly at random.
- Your score increases by the size of the tree which your chosen node belongs to.
- Remove your chosen node and all edges connected to this node. Then proceed to step 1.
Please calculate the expected value of your final score multiplied by N!, modulo 109 + 7.
InputThe first line of input contains one integer N indicating the number of nodes in the initial tree.
Each of the following N - 1 lines contains two integers x and y, indicating that x-th node and y-th node are connected by an edge in the given tree. The nodes are numbered from 1 to N.
- 1 ≤ N ≤ 105
- 1 ≤ x, y ≤ N
- the given graph is a tree
Output one number: the expected value of the final score of this boring game multiplied by N!, modulo 109 + 7.
ExamplesInput2Output
1 2
6Input
3Output
1 2
2 3
34