#P10249. Polynomial Composition Modulo Truncation
Polynomial Composition Modulo Truncation
Polynomial Composition Modulo Truncation
Given a polynomial \(F(x)\) of degree \(n\) and a polynomial \(G(x)\) of degree \(m\), you are required to compute a polynomial \(H(x)\) of degree \(n\) such that
$$H(x) \equiv F(G(x)) \pmod{x^{n+1}}$$
In other words, \(H(x)\) must satisfy:
$$H(x) \equiv \sum_{i=0}^{n} [x^i]F(x)\times G(x)^i \pmod{x^{n+1}}$$
Output each coefficient of \(H(x)\) modulo \(998244353\).
inputFormat
The first line contains two integers \(n\) and \(m\), where \(n\) is the degree of \(F(x)\) and \(m\) is the degree of \(G(x)\).
The second line contains \(n+1\) integers: \(f_0, f_1, \ldots, f_n\), representing the coefficients of \(F(x)\) from degree \(0\) to \(n\).
The third line contains \(m+1\) integers: \(g_0, g_1, \ldots, g_m\), representing the coefficients of \(G(x)\) from degree \(0\) to \(m\).
outputFormat
Output \(n+1\) integers: the coefficients of \(H(x)\) from degree \(0\) to \(n\), separated by spaces. Each coefficient should be given modulo \(998244353\).
sample
2 1
1 2 3
1 1
6 8 3