```cpp
ll tmpf2[19][MAXN<<1];
inline void dnc(ll cnt,ll *pts)
{
static ll tmp[MAXN],tmp2[MAXN];
for(register int i=0;i<cnt;i++)
{
tmpf2[1][i<<1]=(MOD-pts[i])%MOD,tmpf2[1][(i<<1)|1]=1;
}
for(register int l=2;(1<<l)<=(cnt<<1);l++)
{
ll sz=1<<l,szz=sz>>1;
for(register int i=0;i<(cnt<<1);i+=sz)
{
for(register int j=0;j<szz;j++)
{
tmp[j]=tmpf2[l-1][i+j],tmp2[j]=tmpf2[l-1][i+j+szz];
tmp[j+szz]=tmp2[j+szz]=0;
}
for(register int j=0;j<sz;j++)
{
rev[j]=(rev[j>>1]>>1)|((j&1)<<(l-1));
}
NTT(tmp,sz,1),NTT(tmp2,sz,1);
for(register int j=0;j<sz;j++)
{
tmpf2[l][i+j]=(li)tmp[j]*tmp2[j]%MOD;
}
NTT(tmpf2[l]+i,sz,-1);
}
}
}
inline void dnc2(ll cnt,ll *f,ll *pts,ll *res)
{
static ll tmp[MAXN],tmp2[MAXN],tmp3[MAXN];
ll l=0;
while((1<<l)<=(cnt<<1))
{
l++;
}
l--;
while(l>8)
{
ll sz=1<<l,szz=sz>>1;
for(register int i=0;i<(cnt<<1);i+=sz)
{
div(sz-1,szz-1,f+i,tmpf2[l-1]+i,tmp3,tmp);
div(sz-1,szz-1,f+i,tmpf2[l-1]+i+szz,tmp3,tmp2);
for(register int j=0;j<szz;j++)
{
f[i+j]=tmp[j],f[i+j+szz]=tmp2[j];
}
}
l--;
}
ll sz=1<<l;
for(register int i=0;i<(cnt<<1);i+=sz)
{
for(register int j=0;j<sz>>1;j++)
{
ll p=(i>>1)+j,power=1;
res[p]=0;
for(register int k=0;k<sz;k++)
{
res[p]=(res[p]+(li)f[i+k]*power)%MOD;
power=(li)power*pts[p]%MOD;
}
}
}
}
inline void eval(ll fd,ll pcnt,ll *f,ll *pts,ll *res)
{
ll cnt=1;
while(cnt<(fd+pcnt))
{
cnt<<=1;
}
dnc(cnt,pts),dnc2(cnt,f,pts,res);
}
int main()
{
fd=read()+1,pcnt=read();
for(register int i=0;i<fd;i++)
{
f[i]=read();
}
for(register int i=0;i<pcnt;i++)
{
pts[i]=read();
}
eval(fd,pcnt,f,pts,res);
for(register int i=0;i<pcnt;i++)
{
printf("%d\n",res[i]);
}
}
```
by TiCl4 @ 2019-06-20 21:38:36
请自查$n \neq m$的情况
by Zhang_RQ @ 2019-06-20 21:59:12