luogu#P4721. 【模板】分治 FFT

    ID: 3701 远端评测题 1000~5000ms 512MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>分治生成函数快速傅里叶变换 FFT快速数论变换 NTT

【模板】分治 FFT

Background

It can also be solved using polynomial inversion.

Problem Description

Given a sequence g1n1g_{1\dots n - 1}, find the sequence f0n1f_{0\dots n - 1}.

Here, fi=j=1ifijgjf_i=\sum_{j=1}^if_{i-j}g_j, with the boundary condition f0=1f_0=1.

Take the answer modulo 998244353998244353.

Input Format

The first line contains an integer nn.

The second line contains n1n-1 integers g1n1g_{1\dots n - 1}.

Output Format

Output one line with nn integers, representing the values of f0n1f_{0\dots n - 1} modulo 998244353998244353.

4
3 1 2
1 3 10 35
10
2 456 32 13524543 998244352 0 1231 634544 51
1 2 460 1864 13738095 55389979 617768468 234028967 673827961 708520894

Hint

Constraints: 2n1052\leq n\leq 10^5, 0gi<9982443530\leq g_i<998244353.

Translated by ChatGPT 5