Game with Polynomials 2
Time limit5sMemory limit512 MB
Given the coefficients of a polynomial modulo 998244353 and q query points, print the polynomial's value at each point.
- Level
Medium5 of 10
- Topics
- Math, Number theory, Implementation
- Solved
- No attempts yet
Problem
In this problem:
- For convenience, let .
- Fix . This number is prime.
Kipa wanted to set the following interactive problem.
You can call the following function:
evaluate(x): substitutexinto the polynomial and return the remainder modulo .You can call the
evaluatefunction at most times. Your program receives as input and must output the coefficients of modulo .
While preparing the test cases, however, Kipa realized that evaluating a degree- polynomial at up to points in the straightforward way is ! To avoid taking shortcuts as in last year's problem, Kipa asked Kyaryunha, a talented PSer, to somehow write a fast interactor for this problem.
Kyaryunha, in a bind, asks you for help. Let us write the interactor for Kyaryunha!
Input
The first line gives and .
The second line gives integers , separated by spaces.
From the third line, lines give integers .
Every integer from the second line onward is between and .
Output
Print one integer per line, for a total of lines. The integer printed on the -th line must be