3098: Expectation

时间限制:1000 ms 内存限制:128 MB
上传者:
提交:41 通过:14

题目描述

In the Daten City, there are many ghost wreck everyday. To pure the ghost, the heaven send two angels to the city. However the angels getting tired of chasing the ghost in circle, so they decide to destroy some road to make the city no longer has any circle.

They will randomly choose a circle,and destroy the most expensive(Because they are bad angels)in the circle. After serval destroy, the city will no longer has any circle. As the chairman of the city, you want to know the expect (because of the destroy randomly) of value. The value of one situation is the sum value of the road which have't been destroy.

输入格式

The first line contains two integers $n(1\le n \le 2\times 10^5)$ and $m(0 \le m \le 5 \times 10^5)$ ,indicating the number of crosses in the city and the number of road in the city.

The next m line represent the road.

Each line contains three integers $u, v, val(1\le u,v \le n, 1 \le val \le 10^9)$,indicating the road are between cross $u$ and cross $v$, the value is $val$.

输出格式

Output one number indicating the expect ,you should round the answer to the nearest integet.

输入样例 复制

7 12
1 2 9
1 5 2
1 6 3
2 3 5
2 6 7
3 4 6
3 7 3
4 5 6
4 7 2
5 6 3
5 7 6
6 7 1

输出样例 复制

16