#P10106. [GDKOI2023 提高组] 马戏团里你最忙

[GDKOI2023 提高组] 马戏团里你最忙

Problem Description

You are performing a show in a circus.

There is a number with initial value x0x_0. Perform KK operations. In the ii-th operation, pick a number xx uniformly at random from [0,2n)[0, 2^n). With probability pp, xi=xi1orxx_i = x_{i - 1} \operatorname{or} x; with probability 1p1 - p, xi=xi1andxx_i = x_{i - 1} \operatorname{and} x.

The weight of one plan is i=1Kcxi\sum_{i=1}^K c_{x_i}. For each i[0,2n)i \in [0, 2^n), compute, among all plans with xK=ix_K = i, the sum of (weight ×\times probability), taken modulo 998244353998244353.

Input Format

The first line contains four integers n,p,K,x0n, p', K, x_0. Here pp' is the value of pp modulo 998244353998244353.

The second line contains 2n2^n integers. The ii-th integer denotes ci1c_{i - 1}.

Output Format

Output one line with 2n2^n integers separated by spaces. The ii-th integer denotes, among all plans with xK=i1x_K = i - 1, the sum of (weight ×\times probability), taken modulo 998244353998244353.

2 499122177 2 1
1 1 1 1
374341633 374341633 873463809 374341633

2 332748118 10 0
1 2 4 8
178690412 406663623 594339846 223292982

Hint

For 20%20\% of the testdata, K20K \le 20.

For 40%40\% of the testdata, K103K \le 10^3.

For another 10%10\% of the testdata, n=1n = 1.

For another 10%10\% of the testdata, n8n \le 8.

For another 10%10\% of the testdata, p=499122177p' = 499122177.

For another 10%10\% of the testdata, ci=1c_i = 1.

For 100%100\% of the testdata, 0n170 \le n \le 17, 1K1091 \le K \le 10^9, 0x0<2n0 \le x_0 < 2^n, 0p,ci<9982443530 \le p', c_i < 998244353.

Translated by ChatGPT 5