当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

6368:Variance-MST

题目描述
Given a edge-weighted graph, your task is to compute the spanning tree with the smallest variance.

Formally, if $w_{e}$ denotes the weight of edge $e$ then the variance of the tree with $n$ vertices is

$\frac{\sum\limits_{e}(w_e - A)^{2}}{n - 1}$, where $A = \sum\limits_{e}\frac{w_e}{n - 1}$
输入解释
The first line contain a integer $T$ (no morn than 10), the following is $T$ test case, for each test case :

First line contains two positive integer $n$ and $m$ denoting the number of vertices and edges of the graph.

Each of the following $m$ lines contains three positive integers $u_{i}$ , $v_{i}$ , $w_{i}$,denoting the $i_{th}$ edge connects the vertices $u_{i}$ and $v_{i}$ with the weight $w_{i}$.

It is guaranteed the graph is connected.

$2 \leq n \leq 100000$

$1 \leq m \leq 200000$

$1 \leq u_{i}, v_{i} \leq n$

$u_{i} \ne v_{i}$

$0 \leq w_{i} \leq 100000$

It is guaranteed that sum of n less than 400000, m less than 600000.
输出解释
Let $P / Q$ be the number of correct answers, represented as an irreducible fraction. Print $PQ^{-1}$ modulo 998244353.

each test case one line.
输入样例
1
4 6
1 2 2
1 3 4
2 3 6
4 1 7
4 2 5
4 3 3
输出样例
665496236
来自杭电HDUOJ的附加信息
Recommend chendu

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-6368

最后修改于 2020-10-25T23:30:42+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
6000/3000MS(Java/Others) 262144/262144K(Java/Others)