提交记录 5908


用户 题目 状态 得分 用时 内存 语言 代码长度
nantf 1002i. 【模板题】多项式乘法 Wrong Answer 0 75.058 ms 4652 KB C++ 1.10 KB
提交时间 评测时间
2018-09-06 18:30:59 2020-08-01 00:36:10
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=100010,mod=998244353,g=3;
int n,m;
int a[maxn<<2],b[maxn<<2];
int limit=1,l;
int R[maxn<<2];
int quickpow(int a,int b){
	ll ans=1,fac=a;
	while(b){
		if(b&1) ans=ans*fac%mod;
		fac=fac*fac%mod;
		b>>=1;
	}
	return int(ans%mod);
}
void NTT(int *c,int type){
	for(int i=0;i<limit;i++)
		if(i<R[i]) swap(c[i],c[R[i]]);
	for(int mid=1;mid<limit;mid<<=1){
		int wn=quickpow(g,mod-1+type*(mod-1)/(mid<<1));
		for(int r=mid<<1,j=0;j<limit;j+=r){
			int w=1;
			for(int k=0;k<mid;k++,w=1ll*w*wn%mod){
				int x=c[j+k],y=1ll*c[j+k+mid]*w%mod;
				c[j+k]=(x+y)%mod;
				c[j+k+mid]=(x-y+mod)%mod;
			}
		}
	}
	if(type==-1){
		int inv=quickpow(limit,mod-2);
		for(int i=0;i<limit;i++) c[i]=1ll*c[i]*inv%mod;
	}
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=0;i<=n;i++) scanf("%d",a+i);
	for(int i=0;i<=m;i++) scanf("%d",b+i);
	while(limit<n+m){
		limit<<=1;l++;
	}
	for(int i=0;i<limit;i++) R[i]=(R[i>>1]>>1)|((i&1)<<(l-1));
	NTT(a,1);NTT(b,1);
	for(int i=0;i<=limit;i++) a[i]=1ll*a[i]*b[i]%mod;
	NTT(a,-1);
	for(int i=0;i<=n+m;i++) printf("%d ",a[i]);
}

CompilationN/AN/ACompile OKScore: N/A

Subtask #1 Testcase #136.41 us48 KBWrong AnswerScore: 0

Subtask #1 Testcase #274.777 ms4 MB + 476 KBAcceptedScore: 0

Subtask #1 Testcase #334.404 ms1 MB + 840 KBAcceptedScore: 100

Subtask #1 Testcase #434.466 ms1 MB + 828 KBAcceptedScore: 0

Subtask #1 Testcase #540.21 us48 KBWrong AnswerScore: -100

Subtask #1 Testcase #637.92 us48 KBAcceptedScore: 0

Subtask #1 Testcase #736.37 us48 KBAcceptedScore: 0

Subtask #1 Testcase #869.007 ms4 MB + 208 KBAcceptedScore: 0

Subtask #1 Testcase #969.148 ms4 MB + 208 KBAcceptedScore: 0

Subtask #1 Testcase #1041.157 ms2 MB + 452 KBWrong AnswerScore: 0

Subtask #1 Testcase #1175.039 ms4 MB + 556 KBAcceptedScore: 0

Subtask #1 Testcase #1275.058 ms3 MB + 436 KBAcceptedScore: 0

Subtask #1 Testcase #1335.32 us48 KBAcceptedScore: 0


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