#P10007. [集训队互测 2023] 童话

    ID: 11162 远端评测题 3000ms 2048MiB 尝试: 0 已通过: 0 难度: 9 上传者: 标签>集训队互测2023O2优化生成函数拉格朗日反演

[集训队互测 2023] 童话

Background

A fairy tale is only beautiful in truth, yet it is never continued.

A fairy tale is only beautiful in gentleness, yet it is never continued.

Problem Description

Lingluo has recently been learning the prefix sum algorithm, and she wrote the following program:

read(n),read(a);
for(int i=0;i<=n;i++)read(f[i]);
for(int t=1;t<=n;t++){
    for(int i=1;i<=n;i++)f[i]=f[i]+a*f[i-1];
    ans[t]=f[t];
}

She found that when nn is relatively large, this program will time out. Please help write a program to compute ans1,ans2,,ansn\text{ans}_1,\text{ans}_2,\cdots,\text{ans}_n. Since the answers are too large, you only need to output each number modulo 998244353998244353.

Input Format

The first line contains two positive integers n,an,a.

The next line contains n+1n+1 non-negative integers, representing f0,f1,,fnf_0,f_1,\cdots,f_n.

Output Format

Output nn non-negative integers, representing ans1,ans2,,ansn\text{ans}_1,\text{ans}_2,\cdots,\text{ans}_n.

2 1
1 2 0
3 7
10 10
5 9 7 8 0 6 3 2 4 10 1
59 1687 55618 1937320 69557006 549579657 621247830 250099579 483510144 968467040

Hint

Constraints:

For 100%100\% of the testdata, it is guaranteed that 2n1062\leqslant n\leqslant 10^6, 0fi<9982443530\leqslant f_i<998244353, and 1a<9982443531\leqslant a<998244353.

Subtask ID nn\leqslant Special Property Score
11 20002000 55
22 10510^5 A
33 BC
44 BD 1010
55 C
66 5×1045\times10^4
77 10510^5
88 2×1052\times 10^5 1515
99 5×1055\times 10^5
1010 10610^6

Special Property A: It is guaranteed that the number of indices ii such that fi0f_i\ne 0 does not exceed 100100.

Special Property B: It is guaranteed that a=1a=1.

Special Property C: It is guaranteed that for all i[0,n]i\in[0,n], fi=1f_i=1.

Special Property D: It is guaranteed that for all i[0,n]i\in[0,n], fi=(i+22)=(i+2)(i+1)2f_i={i+2\choose 2}=\frac{(i+2)(i+1)}{2}.

Translated by ChatGPT 5