\(\text{Smart}\) has \(1\) magic rings and \(n\) magic beads. Some magic beads have a "mysterious connection". Now you need to place these \(n\) magic beads on the magic ring. There are two magic beads placed in the same position. If you regard magic beads as points and "mysterious connections" as edges, then magic beads and mysterious connections will form a tree. After you place magic beads, if any two edges intersect, the intersection must be at the vertex, otherwise Disastrous consequences will occur.
Now you are required to find how many ways to place the magic orbs to meet the requirements without causing catastrophic consequences.
A positive integer \(n\) in the first line means that there are \(n\) magic beads;
In the next \(n-1\) line, each line has two positive integers \(x, y\), representing the "mysterious connection" between the magic bead numbered \(x\) and the magic bead numbered \(y\).
An integer on a line represents the number of legal schemes, and the answer is modulo \(998244353\).
4
1 2
1 3
2 4
16
For example: There is a mysterious connection between \(n=4, (1,2) (1,3) (2,4)\), then the number of legal schemes is \(16\), and the legal schemes are shown in the figure below:
\(30\%\) data: \(n \le 9\);
Another \(30\%\) data: the tree given is a chain, \(n \le=200000\);
Data for \(100\%\): \(n \le 200000\).
Code is not available!
原文:https://www.cnblogs.com/jiupinzhimaguan/p/13817411.html