You are given a tree that contains \(n\) vertices. Count the number of decompositions of the tree into paths modulo \(998244353\).
A tree decompositions in paths is valid if each vertex belongs to exactly one path (a path can be only a single vertex).
Two decompositions are different if there are two vertices \(v\) and \(u\) that belong to the same path in one of the decompositions but two distinct paths in the other.
Input format
- The first line contains only \(n\) denoting the number of vertices of the tree.
- Each of the following \(n-1\) lines contains space-separated \(v_i, u_i\) describing the \(i^{th}\) edge of vertex (\(v_i, u_i\)).
- \(1 \leq n \leq 2 \times 10^5\)
- \(1 \leq v_i, u_i \leq n \)
- It is guaranteed that the edges form a tree.
Output format
Print an integer that denotes the number of decompositions of the tree into paths modular \(998244353\).
3 1 2 1 3
4
These are four decompositions:
\((1), (2), (3)\)
\((1, 2), (3)\)
\((1, 3), (2)\)
\((2, 1, 3)\).
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor
Login to unlock the editorial
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor