AtCoder Grand Contest 073
C
Product of Max of Sum of Subtree
AtCoder
⌀ 3202
原题
← BD →
翻译中…

Problem Statement

翻译中…

There is a tree with $N$ vertices numbered from $1$ to $N$, where the $i$-th edge connects vertices $A_i$ and $B_i$.

翻译中…

We will now randomly write real numbers between $-(N-1)$ and $1$ (inclusive) on each vertex of this tree. The random number distributions are all independent uniform distributions.

翻译中…

Then, the score of the tree is defined as follows:

翻译中…
  • For each vertex $i$, define $x_i$ as follows:
  • The maximum value of the sum of values written on vertices of connected subgraphs that contain vertex $i$
  • If there exists $i$ that does not satisfy $0 \leq x_i \leq 1$, the tree's score is $0$.
  • Otherwise, the tree's score is $\prod_{1 \leq i \leq N} x_i$.
翻译中…

Find the expected value $\text{mod }{998244353}$ of the tree's score.

翻译中…

Definition of expected value $\text{mod }{998244353}$ It can be proved that the sought expected value is always a rational number. Also, under the constraints of this problem, it can be proved that when the value is expressed as an irreducible fraction $\frac{P}{Q}$, we have $Q \neq 0 \pmod{998244353}$. Therefore, an integer $R$ satisfying $R \times Q \equiv P \pmod{998244353}, 0 \leq R < 998244353$ is uniquely determined. Answer this $R$.

翻译中…

Constraints

翻译中…
  • $1 \leq N \leq 5000$
  • $1 \leq A_i, B_i \leq N$
  • The input graph is a tree.
翻译中…

Input

翻译中…

The input is given from Standard Input in the following format:

翻译中…

N
A_1 B_1
A_2 B_2
\vdots
A_{N-1} B_{N-1}

翻译中…

Output

翻译中…

Output the answer.

翻译中…

样例

Input #1
1
Output #1
499122177
The expected value of the score is $1/2$.
Input #2
2
1 2
Output #2
873463809
The expected value of the score is $1/8$.
Input #3
3
1 2
2 3
Output #3
842653798
The expected value of the score is $13/648$.
Input #4
5
1 2
2 3
3 4
4 5
Output #4
132050425
The expected value of the score is $41/187500$.
Input #5
8
1 2
1 3
1 4
1 5
5 6
5 7
5 8
Output #5
243711918
The expected value of the score is $2477/30064771072$.
题目信息
题号
agc073_c
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。