luogu#P5050. 【模板】多项式多点求值

    ID: 4061 远端评测题 1800ms 256MiB 尝试: 0 已通过: 0 难度: 9 上传者: 标签>数学O2优化快速傅里叶变换 FFT快速数论变换 NTT

【模板】多项式多点求值

Problem Description

Given an nn-degree polynomial f(x)f(x), for each i[1,m]i \in [1,m], compute f(ai)f(a_i).

Input Format

The first line contains two positive integers n,mn,m, representing the degree of the polynomial and the number of points to evaluate.

The second line contains n+1n+1 non-negative integers, giving the coefficients of the polynomial from low degree to high degree.

The third line contains mm non-negative integers, representing aia_i.

Output Format

Output a total of mm lines, each containing 11 non-negative integer.

The number on line ii represents f(ai)f(a_i).

The answer should be taken modulo 998244353998244353.

10 10
18 2 6 17 7 19 17 6 2 12 14
4 15 5 20 2 6 20 12 16 5

18147258
804760733
161737928
73381527
23750
973451550
73381527
525589927
842520242
161737928

Hint

Constraints: n,m[1,64000]n,m \in [1,64000], ai,[xi]f(x)[0,998244352]a_i,[x^i]f(x) \in [0,998244352].

[xi]f(x)[x^i]f(x) represents the coefficient of the ii-th term of f(x)f(x).

Translated by ChatGPT 5