传送门
题解:
对于下降幂多项式 f ( x ) f(x) f(x)考虑其点值生成函数:
F ( x ) = ∑ i = 0 ∞ f ( i ) i ! ⋅ x i F(x)=\sum_{i=0}^\infty\frac{f(i)}{i!}\cdot x^i F(x)=i=0∑∞i!f(i)⋅xi
考虑一个下降幂单项式 x n ‾ x^{\underline{n}} xn的点值生成函数: ∑ i = n ∞ i ! ( n − i ) ! i ! x i = x n exp ( x ) \sum_{i=n}^\infty\frac{i!}{(n-i)!i!}x^i=x^n\exp(x) i=n∑∞(n−i)!i!i!xi=xnexp(x)
设 f ( x ) f(x) f(x)的系数生成函数为 G ( x ) G(x) G(x),则 F ( x ) = e x G ( x ) F(x)=e^xG(x) F(x)=exG(x),且 G ( x ) = e − x F ( x ) G(x)=e^{-x}F(x) G(x)=e−xF(x)
e x e^x ex可以直接泰勒展开。
利用卷积实现点值和系数的转换即可。
代码:
#include<bits/stdc++.h>
#define ll long long
#define re register
#define cs const
using std::cerr;
using std::cout;
cs int mod=998244353;
inline int add(int a,int b){return (a+=b)>=mod?a-mod:a;}
inline int dec(int a,int b){return (a-=b)<0?a+mod:a;}
inline int mul(int a,int b){static ll r;r=(ll)a*b;return r>=mod?r%mod:r;}
inline int power(int a,int b,int res=1){
for(;b;b>>=1,a=mul(a,a))(b&1)&&(res=mul(res,a));
return res;
}
inline void Inc(int &a,int b){(a+=b)>=mod?a-=mod:0;}
inline void Dec(int &a,int b){(a-=b)<0?a+=mod:0;}
inline void Mul(int &a,int b){a=mul(a,b);}
cs int bit=20,SIZE=1<<20|1;
int r[SIZE],*w[bit+1];
int fac[SIZE],ifac[SIZE],inv[SIZE];
inline void init_NTT(){
for(int re i=1;i<=bit;++i)w[i]=new int[1<<i-1];
int wn=power(3,mod-1>>bit);w[bit][0]=1;
for(int re i=1;i<(1<<bit-1);++i)w[bit][i]=mul(w[bit][i-1],wn);
for(int re i=bit-1;i;--i)
for(int re j=0;j<(1<<i-1);++j)w[i][j]=w[i+1][j<<1];
fac[0]=ifac[0]=fac[1]=inv[0]=inv[1]=1;
for(int re i=2;i<SIZE;++i)fac[i]=mul(fac[i-1],i),inv[i]=mul(inv[mod%i],mod-mod/i);
ifac[SIZE-1]=power(fac[SIZE-1],mod-2);
for(int re i=SIZE-2;i;--i)ifac[i]=mul(ifac[i+1],i+1);
}
inline void NTT(int *A,int len,int typ){
for(int re i=0;i<len;++i)if(i<r[i])std::swap(A[i],A[r[i]]);
for(int re i=1,d=1;i<len;i<<=1,++d)
for(int re j=0;j<len;j+=i<<1)
for(int re k=0;k<i;++k){
int &t1=A[j+k],&t2=A[j+k+i],t=mul(t2,w[d][k]);
t2=dec(t1,t),Inc(t1,t);
}
if(typ==-1){
std::reverse(A+1,A+len);
for(int re i=0,inv=power(len,mod-2);i<len;++i)Mul(A[i],inv);
}
}
inline void init_rev(int l){
for(int re i=0;i<l;++i)r[i]=r[i>>1]>>1|((i&1)?l>>1:0);
}
int A[SIZE],B[SIZE],C[SIZE];
signed main(){
#ifdef zxyoi
freopen("FFP_mul.in","r",stdin);
#endif
init_NTT();
int n,m;scanf("%d%d",&n,&m);++n,++m;
int deg=n+m-1,l=1;
while(l<(n+m<<1))l<<=1;init_rev(l);
for(int re i=0;i<n;++i)scanf("%d",A+i);
for(int re i=0;i<m;++i)scanf("%d",B+i);
for(int re i=0;i<deg;++i)C[i]=ifac[i];
NTT(A,l,1),NTT(B,l,1),NTT(C,l,1);
for(int re i=0;i<l;++i)Mul(A[i],C[i]),Mul(B[i],C[i]);
NTT(A,l,-1),NTT(B,l,-1);memset(C,0,sizeof(int)*l);
for(int re i=0;i<deg;++i)C[i]=(i&1)?mod-ifac[i]:ifac[i];
for(int re i=0;i<deg;++i)Mul(A[i],mul(B[i],fac[i]));
memset(A+deg,0,sizeof(int)*(l-deg));
NTT(A,l,1),NTT(C,l,1);
for(int re i=0;i<l;++i)Mul(A[i],C[i]);
NTT(A,l,-1);
for(int re i=0;i<deg;++i)cout<<A[i]<<" ";
return 0;
}