
After air-dropping thousands of papers with cardioid equations, the CS nerd has gained enough confidence to approach the girl at school and possibly talk about some Thanksgiving Feast. However, he has no idea where in the school building she is. The CS nerd can't let his courage drop! Thus, he begins a desperate search to find the girl.
The school that the CS nerd is at has
The CS nerd starts at meeting area
What is the expected time, in seconds, that the CS nerd will take searching for the girl? In other words, if the CS nerd simulates his searching infinite times, what is the average time it takes for him to find the girl?
Constraints
For all subtasks:
The largest time cost of a hallway is
Subtask 1 [10%]
Subtask 2 [30%]
Subtask 3 [20%]
Subtask 4 [40%]
Input Specification
The first line will contain two space-separated integers,
The next
Output Specification
On a single line, output the expected time, in seconds, that the CS nerd will take searching for the girl. Your answer will be judged as correct if it has an absolute or relative error no greater than
Sample Input 1
2 2
1 2 5
1 2 3
Sample Output 1
2.000000
Explanation for Sample Output 1
If the girl is located at meeting area 1, the CS nerd spends
Sample Input 2
3 2
1 2 60
1 3 60
Sample Output 2
120.000000
Sample Input 3
5 5
1 2 1
1 3 1
1 4 1
3 4 1
4 5 1
Sample Output 3
5.733333
Comments
is p6 always going to be the same thing?
Aren't we in the matrix now?