提交记录 15681


用户 题目 状态 得分 用时 内存 语言 代码长度
123456zmy 1002i. 【模板题】多项式乘法 Wrong Answer 0 22.913 ms 7532 KB C++ 1.54 KB
提交时间 评测时间
2021-01-25 10:32:30 2021-01-25 10:32:35
#include<bits/stdc++.h>
#define _SIZE_ 100000
char _b[_SIZE_],*_b1,*_b2;
#define getc() (_b1==_b2?fread(_b,1,_SIZE_,stdin),_b2=_b+_SIZE_,*((_b1=_b)++):*(_b1++))
#define read(__x) {register signed _x(0);register char _c=getc(),_f(0);for(;_c<47;_c=getc())_f=(_c==45);for(;_c>47;_c=getc())_x=_x*10+(_c^48);_f&&(_x=-_x),__x=_x;}
char _d[_SIZE_],*_p=_d;
#define putc(__c) (_p-_d==_SIZE_?fwrite(_d,1,_SIZE_,stdout),_p=_d,*_p++=__c:*_p++=__c)
#define write(__x) {register signed _x=__x;(_x<0)&&(putc(45),_x=-_x);static signed _q[11];register char _t=0;do{_q[_t++]=_x%10,_x/=10;}while(_x);while(_t)putc(_q[--_t]+48);}
#define fwflush() (fwrite(_d,1,_p-_d,stdout),_p=_d)
#define pi 3.14159265358979323846
struct C
{
    double x,y;
    C operator+(const C b)const{return {x+b.x,y+b.y};} 
	C operator-(const C b)const{return {x-b.x,y-b.y};}
	C operator*(const C b)const{return {x*b.x-y*b.y,x*b.y+y*b.x};}
};
using namespace std;
int tmp1,n,m,N;
void fft(C*a,int n,int fl)
{
	if(n==1)return;
	int mid=n>>1;
	C b[n],x__={1,0},x_={cos(2*pi/n),sin(2*pi/n)};;
	for(int i=0;i<mid;i++)b[i]=a[i<<1];
	for(int i=0;i<mid;i++)b[i|mid]=a[i<<1|1];
	fft(b,mid,fl),fft(b+mid,mid,fl);
	for(int i=0;i<mid;i++,x__=x__*x_)
	{
		C x(b[i+mid]*(C){x__.x,fl*x__.y});
		a[i]=b[i]+x,a[i+mid]=b[i]-x;
	}
}
C a[1<<17];
int main()
{
	read(n);read(m);++n,++m,N=min(1<<17,1<<(int)(log2(n+m)+1));
	for(int i=0;i<n;i++)read(a[i].x);
	for(int i=0;i<m;i++)read(a[i].y);
	fft(a,N,1);
	for(int i=0;i<N;i++)a[i]=a[i]*a[i];
	fft(a,N,-1);
	for(int i=0;i<n+m-1;i++){write((int)round(a[i].y/N/2));putc(32);}
	fwflush();
	return 0;
}

CompilationN/AN/ACompile OKScore: N/A

Subtask #1 Testcase #134.7 us48 KBAcceptedScore: 0

Subtask #1 Testcase #222.913 ms7 MB + 364 KBWrong AnswerScore: -100

Subtask #1 Testcase #319.728 ms6 MB + 512 KBAcceptedScore: 100

Subtask #1 Testcase #419.869 ms6 MB + 500 KBAcceptedScore: 0

Subtask #1 Testcase #538.01 us48 KBAcceptedScore: 0

Subtask #1 Testcase #635.77 us48 KBAcceptedScore: 0

Subtask #1 Testcase #736.55 us48 KBAcceptedScore: 0

Subtask #1 Testcase #822.295 ms7 MB + 236 KBWrong AnswerScore: 0

Subtask #1 Testcase #922.296 ms7 MB + 236 KBWrong AnswerScore: 0

Subtask #1 Testcase #1021.806 ms7 MB + 124 KBWrong AnswerScore: 0

Subtask #1 Testcase #1122.904 ms7 MB + 364 KBWrong AnswerScore: 0

Subtask #1 Testcase #1220.197 ms6 MB + 620 KBWrong AnswerScore: 0

Subtask #1 Testcase #1334.29 us48 KBAcceptedScore: 0


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