标签:different jin waiting resid incr initial ora named prompt
There are no more than 20 test cases in the input.
For each test case, the first line contains two integers N and M (1<=N<=3000, 0<=M<=N×N), demonstrating the number of cities and roads in Pushtuar. Cities are numbered from 0 to N-1. In the each of the following M lines, there are three integers x i, y i and c i(c i<=10 7), showing that there is a bidirectional road between x i and y i, while the cost of setting up guarders on this road is c i. We guarantee that the graph is connected. The total cost of the graph is less or equal to 10 9.
The next line contains an integer Q (1<=Q<=10000) representing the number of suspicious road cost changes. In the following Q lines, each line contains three integers X i, Y i and C i showing that the cost of road (X i, Y i) may change to C i(C i<=10 7). We guarantee that the road always exists and C i is larger than the original cost (we guarantee that there is at most one road connecting two cities directly). Please note that the probability of each suspicious road cost change is the same.
For each test case, output a real number demonstrating the expected minimal total cost. The result should be rounded to 4 digits after decimal point.
3 3 0 1 3 0 2 2 1 2 5 3 0 2 3 1 2 6 0 1 6 0 0
6.0000
The initial minimal cost is 5 by connecting city 0 to 1 and city 0 to 2. In the first suspicious case, the minimal total cost is increased to 6; the second case remains 5; the third case is increased to 7. As the result, the expected cost is (5+6+7)/3 = 6.
hen
刷题总结——Genghis Khan the Conqueror (hdu4126)
标签:different jin waiting resid incr initial ora named prompt
原文地址:http://www.cnblogs.com/AseanA/p/7746451.html