#P5264. 多项式三角函数

    ID: 5995 远端评测题 2000ms 125MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>倍增O2优化构造快速数论变换 NTT

多项式三角函数

Problem Description

Given a polynomial A(x)A(x) of degree n1n-1, find a polynomial F(x)F(x) modulo xnx^n such that F(x)sinA(x)F(x)\equiv\sin{A(x)} or F(x)cosA(x)F(x)\equiv\cos{A(x)}.

All operations are performed modulo 998244353998244353.

Input Format

The first line contains two integers n,typen,type. If type=0type=0, compute sin\sin; if type=1type=1, compute cos\cos.

The second line contains nn integers, which are the coefficients a0,a1,,an1a_0,a_1,\cdots,a_{n-1} of the polynomial.

It is guaranteed that a0=0a_0=0.

Output Format

Output one line with nn integers, representing the coefficients f0,f1,,fn1f_0,f_1,\cdots,f_{n-1} of the resulting polynomial.

8 0
0 4 2 6 1 5 3 7
0 4 2 332748113 998244338 931694687 998244320 72887640
8 1
0 4 2 6 1 5 3 7
1 0 998244345 998244345 665496220 332748123 44366450 133099314

Hint

Constraints for 100%100\% of the testdata: n105n\leq10^5, ai[0,998244352]Za_i\in[0,998244352]\cap\mathbb{Z}.

For the first 55 test points, type=0type=0; for the last 55 test points, type=1type=1.

Translated by ChatGPT 5