提交记录 7226


用户 题目 状态 得分 用时 内存 语言 代码长度
_23333 1002. 测测你的多项式乘法 Compile Error 0 0 ns 0 KB C++ 832 B
提交时间 评测时间
2019-01-08 15:34:27 2020-08-01 01:01:29
#define N 280005
#define p 998244353
#define G 332748118
int lim;
int r[N];

inline int POW(int a,int b=p-2,int ans=1){
	for(;b;b>>=1,a=1ll*a*a%p)
		if(b&1) ans=1ll*ans*a%p;
	return ans;
}
void NTT(int *f,int pd){
	for(int i=0;i<lim;i++)
		if(i<r[i]) swap(f[i],f[r[i]]);
	for(int w,len=1;len<lim;len<<=1){
		w=POW(pd,(p-1)/(len<<1));
		for(int b=1,k=0;k<lim;k+=(len<<1),b=1)
			for(int i=k;i<k+len;i++,b=1ll*b*w%p){
				int now=1ll*b*f[i+len]%p;
				f[i+len]=(f[i]-now+p)%p,f[i]=(f[i]+now)%p;
			}
	}
}


void poly_multiply(unsigned *a, int n, unsigned *b, int m, unsigned *c)
{
	for(lim=1;lim<=n+m;lim<<=1);
	for(int i=1;i<lim;i++)
		r[i]=(r[i>>1]>>1)|((i&1)?lim>>1:0);
	NTT(a,3);NTT(b,3);
	for(int i=0;i<lim;i++)
		c[i]=1ll*a[i]*b[i]%p;
	NTT(c,G); int inv=POW(lim);
	for(int i=0;i<=n+m;i++)
                c[i]=1ll*c[i]*inv%p;
}

CompilationN/AN/ACompile ErrorScore: N/A


Judge Duck Online | 评测鸭在线
Server Time: 2026-04-08 20:20:15 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠