Bruce has a directed weighted graph , and the weight of each edge
is denoted as
(
can be negative). For any cycle in the graph, Bruce defined the cycle's weight as the average edges' weight in the cycle. For example, the weight of cycle
is calculated by
, where
is the number of edges in this cycle. Now, Bruce's objective is to find the cycle which has the minimal weight in
.
Input Specification
The first line of input will consist of two integers, and
, which are the number of vertices and the number of edges.
Each of the next lines will consist of three numbers,
,
and
(
,
), which are the edge from
to
with the cost
.
Output Specification
Output the minimal cycle's weight. Answers will be considered correct if they are within an absolute or relative error less than or equal to .
Constraints
For all subtasks:
Subtask 1 [20%]
Subtask 2 [50%]
Note that all test cases are randomly generated.
Sample Input 1
4 5
1 2 5
2 3 5
3 1 5
2 4 3
4 1 3
Sample Output 1
3.66666667
Sample Input 2
2 2
1 2 -2.9
2 1 -3.1
Sample Output 2
-3.00000000
Comments