#P4721. Sequence Reconstruction Problem

    ID: 17965 Type: Default 1000ms 256MiB

Sequence Reconstruction Problem

Sequence Reconstruction Problem

Given a sequence (g_{1\dots n-1}), compute the sequence (f_{0\dots n-1}) defined by the recurrence [ f_0 = 1, \quad f_i = \sum_{j=1}^{i} f_{i-j} \cdot g_j \quad\text{for } i \ge 1, ] All computations are done modulo (998244353).

inputFormat

The input consists of two lines: The first line contains an integer (n), the number of elements in the sequence (f). The second line contains (n-1) space-separated integers representing (g_1, g_2, \dots, g_{n-1}).

outputFormat

Output the sequence (f_0, f_1, \dots, f_{n-1}) in a single line separated by spaces.

sample

4
2 3 4
1 2 7 24