#include <iostream>
const int P = 998244353, O=1<<21;
int N,M,A,i,j,V[O+1],W[O+1];
long long w,c,Z,R;
#define p a[j]
#define q a[j+i]
void G(int a[], int t) {
for (unsigned I = t < 0 ? 0 : 20; I < 21; I -= t) {
i = 1 << I;
Z=3,w=1,R=P>>I+1;
while(R)R>>=!(R & 1&&!(w=w*Z%P)),Z=Z*Z%P;
for (j = 0, c = 1; j < O; c=++j&i?!!(j+=i):c*w%P)
(t < 0) && (q=1LL*q*c%P),
p += q, q=p-q-q+P,
q= 1LL*q*(t>0?c:1)%P,
p%=P;
}
}
main() {
scanf("%d%d",&N,&M);
for (i = 0; i <= N; ++i) scanf("%d",V+i);
for (i = 0; i <= M; ++i) scanf("%d",W+i);
G(V, 1), G(W, 1);
for (i = 0; i < O; ++i) V[i] = c * V[i] * W[i] % P;
G(V, -1);
for (i = 0; i <= N + M; ++i) printf("%lld ", V[(O - i) & (O - 1)] * (c * P - P/O) % P);
}
然后就是大力 golf 了,展示最终成果。这里 15311432\equiv3^{119}。
#import<cstdio>
const int O=1<<21,P=476*O+1;long w,c=1,N,M,A,*j,V[O],W[O],t,Z;void G(long*a){for(auto I=20u*!t;I<21;I+=t?:-1){for(w=15311432,Z=22-I;Z--;w=w*w%P)A=1<<I;for(j=a;j<a+O;c=++j-a&A?!!(j+=A):c*w%P)j[A]=((*j+=j[A]=j[A]%P*(t?c:1)%P)-j[A]*2+P)*(t?:c)%P,*j%=P;}}main(){for(scanf("%ld%ld",&N,&M),t=++N;t;--t)scanf("%ld",V+t);for(N+=M;~M;--M)scanf("%ld",W+M);for(G(V),G(W);t<O;++t)V[t]*=W[t];for(t=1,G(V);N;--N)printf("%ld ",V[O-N]*(P-P/O)%P);}