#6693. [ICPC 2025 Xi'an R] Heart of Darkness

    ID: 6693 传统题 3000ms 512MiB 尝试: 0 已通过: 0 难度: (无) 上传者: 标签>P144542025组合数学生成函数ICPC拉格朗日反演西安

[ICPC 2025 Xi'an R] Heart of Darkness

[ICPC 2025 Xi'an R] Heart of Darkness

题目描述

For a tree $T$, define $v(T)$ as the number of schemes that stain vertices of $T$ in black and white, and satisfy the following conditions:
  • For all black vertices u,vu,v in TT, vertices in the simple path from uu to vv are all black.
  • There are at least kk undirected edges (u,v)(u,v) satisfy uu and vv has different color.

For all nn vertices labeled unrooted tree TT, calculate the sum of v(T)v(T) modulo 998244353998244353.

输入格式

A single line contains two positive integers $n,k$ ($1\le n \le 10^7$, $1\le k \le 5000$).

输出格式

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 $3$ different $T$ those are chains, so they have the same $v(T)$. Denote $0$ as black and $1$ as white, there are $5$ schemes: $(0,0,1),(1,0,0),(1,1,0),(0,1,1),(1,0,1)$. We emphasize that schemes $(1,1,1)$ and $(0,0,0)$ don't satisfy the second condition, and $(0,1,0)$ doesn't satisfy the first one.

Therefore, the answer is 3⋅5=153 \cdot 5 = 15. 标签: P14454|2025|组合数学|生成函数|ICPC|拉格朗日反演|西安

来源

P14454|[ICPC 2025 Xi'an R] Heart of Darkness