首先考虑对于的点值构建
考虑对于的点值构造
所以只需要用普通多项式的系数乘个就得到了点值的
点值还原原多项式只需要乘一个即可
#include<bits/stdc++.h>
using namespace std;
const int RLEN=1<<20|1;
inline char gc(){
static char ibuf[RLEN],*ib,*ob;
(ob==ib)&&(ob=(ib=ibuf)+fread(ibuf,1,RLEN,stdin));
return (ob==ib)?EOF:*ib++;
}
#define gc getchar
inline int read(){
char ch=gc();
int res=0,f=1;
while(!isdigit(ch))f^=ch=='-',ch=gc();
while(isdigit(ch))res=(res+(res<<2)<<1)+(ch^48),ch=gc();
return f?res:-res;
}
#define ll long long
#define re register
#define pii pair<int,int>
#define fi first
#define se second
#define pb push_back
#define cs const
const int mod=998244353,g=3;
inline int add(int a,int b){return a+b>=mod?a+b-mod:a+b;}
inline void Add(int &a,int b){a=add(a,b);}
inline int dec(int a,int b){return a>=b?a-b:a-b+mod;}
inline void Dec(int &a,int b){a=dec(a,b);}
inline int mul(int a,int b){return 1ll*a*b>=mod?1ll*a*b%mod:a*b;}
inline void Mul(int &a,int b){a=mul(a,b);}
inline int ksm(int a,int b,int res=1){for(;b;b>>=1,a=mul(a,a))(b&1)?(res=mul(res,a)):0;return res;}
inline void chemx(int &a,int b){a<b?a=b:0;}
inline void chemn(int &a,int b){a>b?a=b:0;}
cs int N=(1<<18)+1,C=20;
#define poly vector<int>
int rev[N<<2];
poly w[C+1];
inline void init_w(){
int wn=ksm(g,(mod-1)/(1<<C));
for(int i=1;i<=C;i++)w[i].resize(1<<(i-1));
w[C][0]=1;
for(int i=1;i<(1<<(C-1));i++)w[C][i]=mul(w[C][i-1],wn);
for(int i=C-1;i;i--){
for(int j=0;j<(1<<(i-1));j++)
w[i][j]=w[i+1][j<<1];
}
}
inline void ntt(poly &f,int lim,int kd){
for(int i=0;i<lim;i++)if(i>rev[i])swap(f[i],f[rev[i]]);
for(int mid=1,l=1;mid<lim;mid<<=1,l++)
for(int i=0,a0,a1;i<lim;i+=(mid<<1))
for(int j=0;j<mid;j++){
a0=f[i+j],a1=mul(f[i+j+mid],w[l][j]);
f[i+j]=add(a0,a1),f[i+j+mid]=dec(a0,a1);
}
if(kd==-1){
reverse(f.begin()+1,f.begin()+lim);
for(int i=0,inv=ksm(lim,mod-2);i<lim;i++)Mul(f[i],inv);
}
}
inline void init_rev(int lim){
for(int i=0;i<lim;i++)rev[i]=(rev[i>>1]>>1)|((i&1)*(lim>>1));
}
inline poly operator *(poly a,poly b){
int deg=a.size()+b.size()-1,lim=1;
while(lim<deg)lim<<=1;
init_rev(lim);
a.resize(lim),ntt(a,lim,1);
b.resize(lim),ntt(b,lim,1);
for(int i=0;i<lim;i++)Mul(a[i],b[i]);
ntt(a,lim,-1),a.resize(deg);
return a;
}
int fac[N<<2],ifac[N<<2];
inline void init(){
fac[0]=ifac[0]=1;
for(int i=1;i<N;i++)fac[i]=mul(fac[i-1],i);
ifac[N-1]=ksm(fac[N-1],mod-2);
for(int i=N-2;i;i--)ifac[i]=mul(ifac[i+1],i+1);
}
poly a,b,ex;
int main(){
int n=read(),m=read();
init(),init_w();
for(int i=0;i<=n;i++)a.pb(read());
for(int i=0;i<=m;i++)b.pb(read());
for(int i=0;i<=n+m;i++)ex.pb(ifac[i]);
a.resize(n+m+1),b.resize(n+m+1);
a=a*ex,b=b*ex;
for(int i=0;i<=n+m;i++)Mul(a[i],mul(b[i],fac[i]));
for(int i=0;i<=n+m;i++)if(i&1)ex[i]=mod-ex[i];
a=a*ex;
for(int i=0;i<=n+m;i++)cout<<a[i]<<" ";
}