#P9411. 『STA - R2』Gtrimee

『STA - R2』Gtrimee

Problem Description

Let wk(n)w_k(n) be the number of ordered rooted unlabeled trees whose children are ordered and that satisfy the following conditions:

  • The number of nodes n0[1,n]n_0\in[1,n].
  • All nodes with depth kk are not leaves.

Given a fixed positive integer kk, and then given a positive integer nn multiple times, compute wk(n)mod998244353w_k(n)\bmod 998244353.

Here, the depth of a node is defined as the length of the unique simple path from it to the root. For example, the depth of the root is 00.

Input Format

This problem has multiple queries.

The first line contains a positive integer idid, indicating the Subtask ID.

The second line contains two positive integers q,kq,k, where qq is the number of queries.

The next qq lines each contain one positive integer nn, describing a query.

Output Format

Output qq lines. Each line should be wk(n)mod998244353w_k(n)\bmod 998244353 for the corresponding query.

0
5 2
1
2
3
4
5
1
2
3
5
10
0
5 200
1
10
100
1000
10000
1
6918
721868074
972431902
815282281

Hint

Sample Explanation

Explanation for Sample 1:

When k=2k=2, all valid trees with exactly 55 nodes are:

Constraints

This problem uses bundled testdata.

$$\newcommand{\arraystretch}{1.5} \begin{array}{c|c|c|c}\hline\hline \textbf{Subtask} & \bm{n}\le & \textbf{Score} & \textbf{Special Properties}\\\hline \textsf{1} & 5 & 5 \\\hline \textsf{2} & 10^2 & 20\\\hline \textsf{3} & 2\times10^5 & 35 & k=1\\\hline \textsf{4} & 2\times10^5 & 40\\\hline\hline \end{array}$$

For all testdata, 1n,q,k2×1051\le n,q,k\le 2\times10^5.

Translated by ChatGPT 5