提交记录 6545


用户 题目 状态 得分 用时 内存 语言 代码长度
zcysky 1002i. 【模板题】多项式乘法 Accepted 100 63.94 ms 10784 KB C++ 906 B
提交时间 评测时间
2018-10-25 15:57:11 2020-08-01 00:45:42
#include<bits/stdc++.h>
#define N 262145
#define pi acos(-1)
using namespace std;
typedef complex<double> E;
int n,m,l,r[N];
E a[N],b[N];
void FFT(E *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){
		E wn(cos(pi/i),f*sin(pi/i));
		for(int p=i<<1,j=0;j<n;j+=p){
			E w(1,0);
			for(int k=0;k<i;k++,w*=wn){
				E x=a[j+k],y=w*a[j+k+i];
				a[j+k]=x+y;a[j+k+i]=x-y;
			}
		}
	}
}
inline int read(){
	int f=1,x=0;char ch;
	do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');
	do{x=x*10+ch-'0';ch=getchar();}while(ch>='0'&&ch<='9');
	return f*x;
}
int main(){
	n=read();m=read();
	for(int i=0;i<=n;i++)a[i]=read();
	for(int i=0;i<=m;i++)b[i]=read();
	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));
	FFT(a,1);FFT(b,1);
	for(int i=0;i<=n;i++)a[i]=a[i]*b[i];
	FFT(a,-1);
	for(int i=0;i<=m;i++)printf("%d ",(int)(a[i].real()/n+0.5));
}

CompilationN/AN/ACompile OKScore: N/A

Subtask #1 Testcase #136.21 us48 KBAcceptedScore: 0

Subtask #1 Testcase #263.213 ms10 MB + 464 KBAcceptedScore: 0

Subtask #1 Testcase #328.73 ms4 MB + 840 KBAcceptedScore: 100

Subtask #1 Testcase #428.768 ms4 MB + 828 KBAcceptedScore: 0

Subtask #1 Testcase #538.05 us48 KBAcceptedScore: 0

Subtask #1 Testcase #637.59 us48 KBAcceptedScore: 0

Subtask #1 Testcase #736.67 us48 KBAcceptedScore: 0

Subtask #1 Testcase #857.851 ms10 MB + 196 KBAcceptedScore: 0

Subtask #1 Testcase #957.779 ms10 MB + 196 KBAcceptedScore: 0

Subtask #1 Testcase #1052.512 ms9 MB + 952 KBAcceptedScore: 0

Subtask #1 Testcase #1163.536 ms10 MB + 544 KBAcceptedScore: 0

Subtask #1 Testcase #1263.94 ms9 MB + 424 KBAcceptedScore: 0

Subtask #1 Testcase #1334.75 us48 KBAcceptedScore: 0


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