#P4316. 绿豆蛙的归宿
绿豆蛙的归宿
Description
You are given a directed acyclic graph with vertices and edges. The start vertex is , and the terminal vertex is . Each edge has a length. From the start, every vertex is reachable, and every vertex can reach the terminal.
Green Bean Frog starts from the start and moves to the terminal. Upon arriving at a vertex that has outgoing edges, the frog may choose any outgoing edge to leave the vertex, and each edge is chosen with probability . What is the expected total length of the path from the start to the terminal?
Input Format
The first line contains two integers representing the number of vertices and the number of edges .
Lines through each contain three integers , indicating there is a directed edge from to with length .
Output Format
Output a single real number: the answer, rounded to two decimal places.
4 4
1 2 1
1 3 2
2 3 3
3 4 4
7.00
Hint
- Constraints
- For of the testdata, .
- For of the testdata, .
- For of the testdata, .
- For of the testdata, , , , , and the graph has no parallel edges or self-loops.
Translated by ChatGPT 5
京公网安备 11011102002149号