当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

7211:Counting Stickmen

题目描述
Namesolo has fallen in love with the game Stick Fight. But when he is playing the game, he wonders how to find out the number of stickmen in the game.



In this question, we define the stick man as shown in the picture above. It has a chain of length $1$ as the head, two chains of length $2$ as the arms, a chain of length $1$ as the body, and two chains of length $1$ as the legs. For example, the red part in this picture can be viewed as a stick man, with chain $(2,3)$ to be the head, chains $(3,4,6)$ and $(3,9,10)$ to be the arms, chain $(3,5)$ to be the body, and chains $(5,7)$ and $(5,8)$ to be the legs.

The game can be viewed as a tree, and Namesolo wants to know how many stickmen are there. Please note that two stickmen are different when there is at least one different edge between the two edge sets that make up the two stickmen.

Because the answer may be too large, Namesolo wants to know the answer modulo $998244353$.
输入解释
The first line of input contains one integer $T\ (1\le T\le 15)$, indicating the number of test cases.

For each test case, the first line contains an integer $n$ ($1\le n \le 5\times 10^5$), indicating the number of vertices in the tree. Each of the following $n-1$ lines contains two integers $a,b$ ($1 \le a,b \le n$), indicating that there is an edge connecting $a$ and $b$ in the tree.

It is guaranteed that the sum of $n$ over all cases won't exceed $3 \times 10^6$.
输出解释
For each test case, output an integer representing the answer modulo $998244353$.
输入样例
1
9
1 2
2 3
3 4
2 5
5 6
2 7
7 8
7 9
输出样例
1

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-7211

最后修改于 2022-09-15T06:17:25+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
18000/9000MS(Java/Others) 524288/524288K(Java/Others)