#B. 树上游戏(tree)

    Type: Default 1000ms 256MiB

树上游戏(tree)

No testdata at current.

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

小巡和小由有一颗 nn 个节点的树。小巡和小由每个人会在 n(n1)2\dfrac{n(n-1)}{2} 条简单路径中选一条。记 XX 表示两条路径相交的长度。

你需要告诉小巡 E(X2)E(X^2),即 X2X^2 的期望值。对 998244353998244353 取模。

输入格式

第一行一个 TT 表示测试组数量。

每个测试组,第一行一个正整数 nn

接下来 n1n-1 行,每行两个正整数,描述了一条树边。

输出格式

TT 行,每行一个正整数表示答案。

样例

【样例输入】

2
3
1 2
2 3
5
1 2
1 5
3 2
4 2

【样例输出】

443664158
918384806

数据范围

对于所有数据,1T101\leq T\leq 101n2×1051\leq n\leq 2\times 10^5

测试点编号 nn\leq 特殊性质
11 100100
22 50005000
33 2×1052\times 10^5 \checkmark
44

特殊性质:v=u+1v=u+1

NOIP 模拟赛(十)

Not Attended
Status
Done
Rule
OI
Problem
4
Start at
2024-11-7 7:45
End at
2024-11-7 12:15
Duration
4.5 hour(s)
Host
Partic.
10