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

    ID: 14398 远端评测题 3000ms 512MiB 尝试: 0 已通过: 0 难度: 9 上传者: 标签>2025组合数学生成函数ICPC拉格朗日反演西安

[ICPC 2025 Xi'an R] Heart of Darkness

题目描述

For a tree TT, define v(T)v(T) as the number of schemes that stain vertices of TT 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,kn,k (1n1071\le n \le 10^7, 1k50001\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 33 different TT those are chains, so they have the same v(T)v(T). Denote 00 as black and 11 as white, there are 55 schemes: (0,0,1),(1,0,0),(1,1,0),(0,1,1),(1,0,1)(0,0,1),(1,0,0),(1,1,0),(0,1,1),(1,0,1). We emphasize that schemes (1,1,1)(1,1,1) and (0,0,0)(0,0,0) don't satisfy the second condition, and (0,1,0)(0,1,0) doesn't satisfy the first one.

Therefore, the answer is 35=153 \cdot 5 = 15.