#P14454. [ICPC 2025 Xi'an R] Heart of Darkness
[ICPC 2025 Xi'an R] Heart of Darkness
题目描述
For a tree , define as the number of schemes that stain vertices of in black and white, and satisfy the following conditions:
- For all black vertices in , vertices in the simple path from to are all black.
- There are at least undirected edges satisfy and has different color.
For all vertices labeled unrooted tree , calculate the sum of modulo .
输入格式
A single line contains two positive integers (, ).
输出格式
A single integer as the answer.
3 1
15
6 2
17286
30 9
434031055
114514 2520
136362204
提示
For the first test case, there are only different those are chains, so they have the same . Denote as black and as white, there are schemes: . We emphasize that schemes and don't satisfy the second condition, and doesn't satisfy the first one.
Therefore, the answer is .
京公网安备 11011102002149号