提交记录 8949


用户 题目 状态 得分 用时 内存 语言 代码长度
wangtian1213 1002i. 【模板题】多项式乘法 Accepted 100 72.216 ms 4652 KB C++11 1.17 KB
提交时间 评测时间
2019-03-26 16:57:21 2020-08-01 01:27:26
#include <bits/stdc++.h>
using namespace std;
const int Mod=998244353;
const int N=400005;
int R[N],a[N],b[N],n,m;
int read(int &a) {
	char ch=getchar(); a=0;
	while (ch<'0' || ch>'9') ch=getchar();
	while (ch>='0' && ch<='9') a=a*10+ch-'0',ch=getchar();
	return a;
}
int Pow(int x,int y) {
	int res=1;
	while (y) {
		if (y&1) res=1ll*res*x%Mod;
		x=1ll*x*x%Mod; y>>=1;
	}
	return res%Mod;
}
void NTT(int *A,int f) {
	for (int i=0; i<n; i++) if (i<R[i]) swap(A[i],A[R[i]]);
	for (int i=1; i<n; i<<=1) {
		int gn=Pow(3,(Mod-1)/(i<<1)),x,y;
		for (int j=0; j<n; j+=(i<<1)) {
			int g=1;
			for (int k=0; k<i; k++,g=1ll*g*gn%Mod) {
				x=A[j+k],y=1ll*g*A[i+j+k]%Mod;
				A[j+k]=(x+y)%Mod,A[i+j+k]=(x-y+Mod)%Mod;
			}
		}
	}
	if (f==1) return;
	reverse(A+1,A+n);
	int y=Pow(n,Mod-2);
	for (int i=0; i<n; i++) A[i]=1ll*A[i]*y%Mod;
}
int main() {
	read(n),read(m);
	for (int i=0; i<=n; i++) read(a[i]);
	for (int i=0; i<=m; i++) read(b[i]);
	int L=0;
	m+=n; for (n=1; n<=m; n<<=1) L++;
	for (int i=0; i<n; i++) R[i]=(R[i>>1]>>1)|((i&1)<<(L-1));
	NTT(a,1); NTT(b,1);
	for (int i=0; i<n; i++) a[i]=1ll*a[i]*b[i]%Mod;
	NTT(a,-1);
	for (int i=0; i<=m; i++) printf("%d ",a[i]); printf("\n"); 
	return 0;
}

CompilationN/AN/ACompile OKScore: N/A

Subtask #1 Testcase #136.61 us48 KBAcceptedScore: 0

Subtask #1 Testcase #271.687 ms4 MB + 476 KBAcceptedScore: 100

Subtask #1 Testcase #333.022 ms1 MB + 840 KBAcceptedScore: 0

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

Subtask #1 Testcase #539.87 us48 KBAcceptedScore: 0

Subtask #1 Testcase #637.62 us48 KBAcceptedScore: 0

Subtask #1 Testcase #737.58 us48 KBAcceptedScore: 0

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

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

Subtask #1 Testcase #1061.263 ms3 MB + 964 KBAcceptedScore: 0

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

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

Subtask #1 Testcase #1335.25 us48 KBAcceptedScore: 0


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