AtCoder Grand Contest 058
F
Authentic Tree DP
AtCoder
未评级
原题
← E→
翻译中…

Problem Statement

翻译中…

For an undirected tree $t$, let us define a rational number $f(t)$ as follows.

翻译中…
  • Let $n$ be the number of vertices in $t$.
  • If $n=1$: Let $f(t)=1$.
  • If $n \geq 2$:
  • For an edge $e$ in $t$, we denote by $t_x(e)$ and $t_y(e)$ the two trees that result from deleting $e$ from $t$ (in arbitrary order).
    • Let $f(t)=(\sum_{e \in t} f(t_x(e)) \times f(t_y(e)))/n$.
翻译中…

You are given a tree $T$ with $N$ vertices numbered $1$ to $N$. The $i$-th edge connects Vertex $A_i$ and Vertex $B_i$.

翻译中…

Find the value $f(T)$ $\text{mod }{998244353}$.

翻译中…

What is a rational number $\text{mod }{998244353}$? Under the Constraints of this problem, when the sought rational number is represented as $\frac{P}{Q}$, it can be proved that $Q \neq 0 \pmod{998244353}$. Therefore, there is a unique integer $R$ such that $R \times Q \equiv P \pmod{998244353}, 0 \leq R < 998244353$. Find this $R$.

翻译中…

Constraints

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

Input

翻译中…

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

翻译中…

Print the answer.

翻译中…

样例

Input #1
2
1 2
Output #1
499122177
We have $f(T)=1/2$.
Input #2
3
1 2
2 3
Output #2
332748118
We have $f(T)=1/3$.
Input #3
4
1 2
2 3
3 4
Output #3
103983787
Input #4
10
4 5
1 9
6 1
8 4
5 9
4 7
3 10
5 2
4 3
Output #4
462781191
题目信息
题号
agc058_f
时间限制
2 s
内存限制
1024 MB

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