P5050 [Template] Multipoint Evaluation of a Polynomial
Description
Given an $n$-degree polynomial $f(x)$, for each $i \in [1,m]$, compute $f(a_i)$.
Input Format
The first line contains two positive integers $n,m$, representing the degree of the polynomial and the number of points to evaluate.
The second line contains $n+1$ non-negative integers, giving the coefficients of the polynomial from low degree to high degree.
The third line contains $m$ non-negative integers, representing $a_i$.
Output Format
Output a total of $m$ lines, each containing $1$ non-negative integer.
The number on line $i$ represents $f(a_i)$.
The answer should be taken modulo $998244353$.
Explanation/Hint
Constraints: $n,m \in [1,64000]$, $a_i,[x^i]f(x) \in [0,998244352]$.
$[x^i]f(x)$ represents the coefficient of the $i$-th term of $f(x)$.
Translated by ChatGPT 5