11289: [yosupo] Polynomial - Inv of Formal Power Series
[Creator : ]
Description
You are given a formal power series $f(x) = \sum_{i=0}^{N-1} a_i x^i \in \mathbb{F}\_{998244353}[[x]]$ with $a_0 \ne 0$.
Calculate the first $N$ terms of $\frac{1}{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{F}\_{998244353}[[x]]$ such that
$f(x) g(x) \equiv 1 \pmod{x^N}.$
Calculate the first $N$ terms of $\frac{1}{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{F}\_{998244353}[[x]]$ such that
$f(x) g(x) \equiv 1 \pmod{x^N}.$
Input
$N$
$a_0$ $a_1$ $\cdots$ $a_{N - 1}$
$a_0$ $a_1$ $\cdots$ $a_{N - 1}$
Output
$b_0$ $b_1$ $\cdots$ $b_{N - 1}$
Constraints
- $1 \leq N \leq 5\times 10^5$
- $0 \leq a_i < 998244353$
- $a_0 \neq 0$
- $0 \leq a_i < 998244353$
- $a_0 \neq 0$
Sample 1 Input
5
5 4 3 2 1
Sample 1 Output
598946612 718735934 862483121 635682004 163871793