TouchStone
  Please Login
Login Sign Up
 Homepage  Problem Set  Examinations  Submissions  Discussions  Statistics
  • Home
  • Problem Set
  • P3217
  • Problem
  • P3217多项式多点求值
    Limits : Time Limit : - MS   Memory Limit : - KB
    Judgment Tips : 4s 512m
    Description

    给你一个多项式f(x)和n个数a1,a2,...,an,求f(a1),f(a2),...,f(an),答案mod P,其中P=998244353。

    Input Format

    第一行两个数deg(f)和n。
    第二行deg(f)+1个数,表示f0,f1,...,fdeg(A)。
    第三行n个整数a1,a2,...,an。

    Output Format

    输出n行,每行一个整数,第i行的数表示f(ai) mod P的值。

    Sample Input

    2 3
    1 2 1
    1 2 4

    Sample Output

    4
    9
    25

    Hint

    deg(f)<=50000,n<=50000
    每个系数、ai都是0到P-1的整数。