#P5264. 多项式三角函数
多项式三角函数
Problem Description
Given a polynomial of degree , find a polynomial modulo such that or .
All operations are performed modulo .
Input Format
The first line contains two integers . If , compute ; if , compute .
The second line contains integers, which are the coefficients of the polynomial.
It is guaranteed that .
Output Format
Output one line with integers, representing the coefficients 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 of the testdata: , .
For the first test points, ; for the last test points, .
Translated by ChatGPT 5