#P4239. 【模板】任意模数多项式乘法逆

【模板】任意模数多项式乘法逆

Description

Given a polynomial F(x)F(x), find a polynomial G(x)G(x) such that F(x)G(x)1(modxn)F(x) * G(x) \equiv 1 ( \mathrm{mod\:} x^n ). Coefficients are taken modulo 109+710^9+7.

Input Format

First input an integer nn, indicating that F(x)F(x) has degree n1n-1. Then input nn integers; the ii-th integer aia_i denotes the coefficient of the term of F(x)F(x) with degree i1i-1.

Output Format

Output nn integers; the ii-th integer bib_i denotes the coefficient of the term of G(x)G(x) with degree i1i-1.

5
1 6 3 4 9
1 1000000001 33 999999823 1020

Hint

1n1051 \leq n \leq 10^5, 0ai1090 \leq a_i \leq 10^9.

Translated by ChatGPT 5