Short Random Problem
Time limit6sMemory limit512 MB
Given a tree whose edge lengths are independent uniform random reals in [0, 1], find the expected diameter modulo 10^9+7.
- Level
Hard9 of 10
- Topics
- Tree, Probability, Dynamic programming, Combinatorics
- Solved
- No attempts yet
Problem
This contest has many other problems besides this one, so let us keep it short.
You are given a tree with vertices. The length of each edge is a real number chosen independently and uniformly at random between and . Find the expected value of the diameter of this tree.
Input
The first line contains one integer (), the number of vertices.
Each of the next lines contains two integers , (, ), the endpoints of the -th edge.
Output
Print the answer modulo . The expected diameter is a rational number with and coprime, and is not divisible by . Print the integer between and such that is divisible by .