#P5265. Power Series Transformation: arcsin/atan of a Polynomial
Power Series Transformation: arcsin/atan of a Polynomial
Power Series Transformation: arcsin/atan of a Polynomial
You are given a polynomial \( A(x) = a_0 + a_1x + \cdots + a_{n-1}x^{n-1} \) with degree at most \( n-1 \) under modulo \(998244353\). It is guaranteed that \(a_0 = 0\) so that the power series of the inverse trigonometric functions are well-defined.
Your task is to compute a polynomial \( F(x) \) modulo \( x^n \) such that either
[ F(x) \equiv \arcsin,A(x) \equiv \sum_{k \ge 0} \frac{(2k)!}{4^k (k!)^2 (2k+1)} \Bigl(A(x)\Bigr)^{2k+1} \pmod{x^n}, ]
or
[ F(x) \equiv \arctan,A(x) \equiv \sum_{k \ge 0} \frac{(-1)^k}{2k+1} \Bigl(A(x)\Bigr)^{2k+1} \pmod{x^n}. ]
All arithmetic operations are performed modulo \(998244353\). The input will specify which function to use.
inputFormat
The first line contains two integers \(t\) and \(n\) (\(1 \le t \le 2\), \(1 \le n \le N\)), where \(t = 1\) means you should compute \(\arcsin\,A(x)\) and \(t = 2\) means you should compute \(\arctan\,A(x)\).
The second line contains \(n\) space-separated integers \(a_0, a_1, \dots, a_{n-1}\) (each between 0 and 998244352) representing the coefficients of \(A(x)\). It is guaranteed that \(a_0 = 0\).
outputFormat
Output \(n\) space-separated integers \(F_0, F_1, \dots, F_{n-1}\) where \(F(x) = F_0 + F_1x + \cdots + F_{n-1}x^{n-1}\) is the computed polynomial modulo \(998244353\) satisfying the required relation.
sample
1 5
0 1 0 0 0
0 1 0 166374059 0