#P7605. [2018年杭电多校]Variance-MST
[2018年杭电多校]Variance-MST
Variance-MST
Problem Description
Given a edge-weighted graph, your task is to compute the spanning tree with the smallest variance. Formally, if denotes the weight of edge then the variance of the tree with vertices is , where
Input
The first line contain a integer (no morn than 10), the following is test case, for each test case : First line contains two positive integer and denoting the number of vertices and edges of the graph. Each of the following lines contains three positive integers , , ,denoting the edge connects the vertices and with the weight . It is guaranteed the graph is connected. It is guaranteed that sum of n less than 400000, m less than 600000.
Output
Let be the number of correct answers, represented as an irreducible fraction. Print modulo 998244353. each test case one line.
Sample Input
1
4 6
1 2 2
1 3 4
2 3 6
4 1 7
4 2 5
4 3 3
Sample Output
665496236
Source
2018 Multi-University Training Contest 6