11299: [yosupo] Polynomial - Log of Formal Power Series (Sparse)
[Creator : ]
Description
You are given a formal power series $f(x) = \sum_{i=0}^{N-1} a_i x^i \in \mathbb{Q}[[x]]$ with $a_0 = 1$.
Only $K$ coefficients of $f$ are non-zero, and only such coefficients $a_{i_k}$ are given from input.
Calculate the first $N$ terms of $\log(f(x)) = \sum_{i=0}^{\infty} b_i x^i$.
In other words, find $g(x) = \sum_{i=0}^{N-1} b_i x^i \in \mathbb{Q}[[x]]$ such that $b_0 = 0$ and
$f(x) \equiv \sum_{k=0}^{N-1} \frac{g(x)^k}{k!} \pmod{x^N}.$
Print the coefficients modulo $998244353$.
Only $K$ coefficients of $f$ are non-zero, and only such coefficients $a_{i_k}$ are given from input.
Calculate the first $N$ terms of $\log(f(x)) = \sum_{i=0}^{\infty} b_i x^i$.
In other words, find $g(x) = \sum_{i=0}^{N-1} b_i x^i \in \mathbb{Q}[[x]]$ such that $b_0 = 0$ and
$f(x) \equiv \sum_{k=0}^{N-1} \frac{g(x)^k}{k!} \pmod{x^N}.$
Print the coefficients modulo $998244353$.
Input
$N$ $K$
$i_0$ $a_{i_0}$
$\vdots$
$i_{K-1}$ $a_{i_{K-1}}$
$i_0$ $a_{i_0}$
$\vdots$
$i_{K-1}$ $a_{i_{K-1}}$
Output
$b_0$ $b_1$ $\cdots$ $b_{N - 1}$
Constraints
- $1 \leq N \leq 10^6$
- $1 \leq K \leq 10$
- $0 = i_0 < \cdots < i_{K-1} \leq N - 1$
- $1 \leq a_{i_k} < 998244353$
- $a_0 = 1$
- $1 \leq K \leq 10$
- $0 = i_0 < \cdots < i_{K-1} \leq N - 1$
- $1 \leq a_{i_k} < 998244353$
- $a_0 = 1$
Sample 1 Input
5 2
0 1
2 1
Sample 1 Output
0 0 1 0 499122176
Sample 2 Input
10 5
0 1
1 1
2 499122179
3 166374064
4 291154613
Sample 2 Output
0 1 2 3 4 307791995 131712787 793247753 831003798 590204334