J.The least average cost
Description:
Given a weighted directed graph,try to find a circle that the ratio of the sum of weight and the number of edges is the minimum.
Input:
Input contains multiple test cases,ended by EOF.The first line of each case is two positive integers,N(N<=100),M(M<=N*N/2),standing for the number of vertexes and edges.Then M lines following,each line has 3 integers,u,v,w(0<w<=1000),standing for the weight of vertex u to v is w.
Output:
Output the minimum ratio of the circle,accurate to 3 decimal places.if the circle doesn't exit,output"INF";
Sample Input:
4 5
1 2 1
2 4 2
2 3 2
3 1 1
4 3 3
6 6
1 2 2
2 3 2
3 1 2
4 5 1
5 6 1
6 4 1
Sample Output:
1.333
1.000
题解:
代码:
暂时没有做出来。