任意模数FFT时记M为sqrt(mo)
将每个数a分为a/M,a%M后分别进行三次实数FFT
const LL mo=1e9+7;const LL M=sqrt(mo);const LDB pi=acos(-1); LL cunt[511][511]; struct cp{ LDB r,i; }a1[511][1024],a2[511][1024],tmp[1024]; inline cp operator +(cp a,cp b) { return((cp){a.r+b.r,a.i+b.i});}; inline cp operator -(cp a,cp b) { return((cp){a.r-b.r,a.i-b.i});}; inline cp operator *(cp a,cp b) { return((cp){a.r*b.r-a.i*b.i,a.i*b.r+a.r*b.i});}; void FFT(cp a[],int n,int fl){ for (int i=1,j=n/2;i>1);j&k;j^=k,k>>=1); j^=k; } for (int i=2;i<=n;i<<=1){ cp w;w.r=cos(fl*2*pi/i);w.i=sin(fl*2*pi/i); for (int j=0;j