#P3199. [HNOI2009] 最小圈
[HNOI2009] 最小圈
Description
Consider a weighted directed graph and . Each edge (, ) has weight . Let .
A sequence () is a cycle in if and only if () and are both in . We call the length of cycle , and set . The average value of cycle is defined as
$$\mu(c)= \frac 1 k \sum\limits_{i=1}^{k} w_{c_i,c_{i+1}}.$$Let be the minimum average value over all cycles in .
Given and , compute the minimum average value over all cycles in .
Input Format
The first line contains two positive integers and , separated by a space. Here and denote the number of vertices and edges, respectively.
The next lines each contain three numbers , indicating there is an edge with weight . Note that edge weights can be real numbers. The input guarantees that the graph is connected, contains at least one cycle, and there exists a vertex that can reach all other vertices.
Output Format
Output a real number , printed with digits after the decimal point.
4 5
1 2 5
2 3 5
3 1 5
2 4 3
4 1 3
3.66666667
2 2
1 2 -2.9
2 1 -3.1
-3.00000000
Hint
- Constraints: For of the testdata, , , , and .
- Note: There exists an solution; an solution also passes.
Translated by ChatGPT 5
京公网安备 11011102002149号