P29014 [洛谷] [CmdOI2019] Computational Power Training
省选
题目描述

Background

Recently, the problem setter joyfully learned how to solve quadratic equations.

One night in the dormitory, the problem setter dreamed of a country that uses a $k$-ary system. Following the customs, the problem setter also uses a $k$-ary system here.

Of course, the people in this country are also proficient in mathematics, so the problem setter, who cannot solve quadratic equations, did not escape computational power training.

Problem Description

The problem setter wrote $n$ $k$-ary natural numbers on a piece of paper. Due to his laziness, these numbers do not have too many digits and none exceed $m$ digits.

To train computational power, he would randomly select a subsequence (allowing no numbers to be chosen) and then add these numbers together.

He found carrying too troublesome, so he simply stipulated that addition should not carry over.

After calculating a few times, he suddenly wanted to know the number of ways to obtain each number, but he was too inexperienced to calculate it. After much thought, he was suddenly awakened by the alarm clock.

He found this problem interesting and had to seek help from you, who can easily solve countless algebra problems with one hand, to help calculate it.

Formal Problem Statement: For a sequence $A$, define its weight $W(A)$ as the sum of the elements in $A$ using $k$-ary non-carrying addition.

Given $m, k$, and a sequence $S$ of length $n$. It is guaranteed that $S \subseteq [0, k^m) \cap \mathbb{Z}$.

For $t = 0, 1, 2, ..., k^m-1$, calculate the value of the following expression:

$${\rm Ans}[t]=\sum\limits_{\text{R is a subsequence of S}}\big[W(R)=t\big]$$

Note: According to the correct problem statement, it can be deduced that $\sum\limits_{t=0}^{k^m-1}{\rm Ans}[t]=2^n$.

Input Format

The first line contains three integers $n, k, m$, as described in the problem.

The second line contains $n$ integers separated by spaces, representing the numbers on the paper.

(Note: The numbers on the paper are all $k$-ary numbers)

Output Format

Output $k^m$ lines. On the $i$-th line, output the number of ways to obtain the number $i-1$, modulo $998244353$.

Sample Input and Output

Input Sample #1

3 5 1
1 2 3

Output Sample #1

2
2
1
2
1

Input Sample #2

5 6 1
1 1 4 5 1 4

Output Sample #2

8
7
4
2
4
7

Notes

Sample Explanation

For Sample #1, there are $2^3=8$ ways to select subsequences:

  1. Select nothing, the sum is $0$
  2. Select $1$, the sum is $1$
  3. Select $2$, the sum is $2$
  4. Select $3$, the sum is $3$
  5. Select $1+2$, the sum is $3$
  6. Select $1+3$, the sum is $4$
  7. Select $2+3$, the sum is $0$ (since it's a $5$-ary system, it would normally become $10$, but without carrying, it remains $0$)
  8. Select $1+2+3$, the sum is $1$

Thus, the number of ways to obtain 0, 1, 2, 3, 4 are 2, 2, 1, 2, 1 respectively.

Data Range and Constraints

Test Case Number n k m Total Points
#1 $20$ $5$ $4$ $5$
#2 $1000$ $5$ $4$ $5$
#3~4 $10^6$ $5$ $5$ $10$
#5 $10^6$ $5$ $6$ $10$
#6~7 $10^6$ $5$ $7$ $20$
#8 $20$ $6$ $4$ $5$
#9 $1000$ $6$ $4$ $5$
#10~11 $10^6$ $6$ $4$ $10$
#12~14 $10^6$ $6$ $6$ $30$
输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
3 5 1 1 2 3
样例输出
2 2 1 2 1