#Q86. 「一本通 3.3 练习 1」最小圈
「一本通 3.3 练习 1」最小圈
Description
Original source: HNOI 2009
Consider a weighted directed graph with , where each edge has a weight defined as . Let . A cycle in exists if and only if both and are in , where is called the length of cycle . Let , and define the average value of cycle as:
That is, the average of the weights of all edges in .
Let be the minimum average value among all cycles in . The goal is: given a graph and , compute the minimum average value of all cycles in .
Input Format
The first line contains two positive integers and , separated by a space, where and , representing the number of vertices and edges in the graph, respectively.
The next lines each contain three space-separated numbers , indicating an edge with weight .
The input guarantees that the graph is connected, contains at least one cycle, and has at least one vertex that can reach all other vertices.
Output Format
Output only one real number , rounded to 8 decimal places.
Sample 1
4 5
1 2 5
2 3 5
3 1 5
2 4 3
4 1 3
3.66666667
Sample 2
2 2
1 2 -2.9
2 1 -3.1
-3.00000000
Data Range and Hints
For of the data, ;
For of the data, ;
For of the data, .
The input ensures .