#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#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};}
};
const int _lg2[]={0,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3};
using namespace std;
int tmp1,n,m,N;
int lg2(int i)
{
int tmp(0);
if(i>65535)tmp|=16,i>>=16;
if(i>255)tmp|=8,i>>=8;
if(i>15)tmp|=4,i>>=4;
return tmp+_lg2[i];
}
double co[21],si[21];
void fft(C*a,int n)
{
if(n==1)return;
int mid=n>>1;
C x__={1,0},x_={co[lg2(n)],si[lg2(n)]};
fft(a,mid),fft(a+mid,mid);
for(int i=0;i<mid;i++,x__=x__*x_)
{
C x(a[i+mid]*(C){x__.x,x__.y});
a[i+mid]=a[i]-x,a[i]=a[i]+x;
}
}
void ifft(C*a,int n)
{
if(n==1)return;
int mid=n>>1;
C x__={1,0},x_={co[lg2(n)],si[lg2(n)]};
ifft(a,mid),ifft(a+mid,mid);
for(int i=0;i<mid;i++,x__=x__*x_)
{
C x(a[i+mid]*(C){x__.x,-x__.y});
a[i+mid]=a[i]-x,a[i]=a[i]+x;
}
}
C a[1<<21];
int r[1<<21];
void rev(C*a,int n){for(int i=0;i<n;i++)if(i<r[i])swap(a[i],a[r[i]]);}
int main()
{
for(int i=0;i<=20;i++)co[i]=cos(2*pi/(1<<i)),si[i]=sin(2*pi/(1<<i));
int l_n(0);
read(n);read(m);++n,++m,N=min(1<<21,1<<(l_n=(int)(log2(n+m)+1)));
for(int i=0;i<N;i++)r[i]=(r[i>>1]>>1)|((i&1)<<(l_n-1));
for(int i=0;i<n;i++)read(a[i].x);
for(int i=0;i<m;i++)read(a[i].y);
rev(a,N);
fft(a,N);
for(int i=0;i<N;i++)a[i]=a[i]*a[i];
rev(a,N);
ifft(a,N);
for(int i=0;i<n+m-1;i++){write((int)round(a[i].y/N/2));putc(32);}
fwflush();
return 0;
}
Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
Subtask #1 Testcase #1 | 36.92 us | 52 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #2 | 28.381 ms | 6 MB + 668 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #3 | 11.75 ms | 3 MB + 8 KB | Accepted | Score: 100 | 显示更多 |
Subtask #1 Testcase #4 | 11.904 ms | 2 MB + 1020 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #5 | 39.37 us | 52 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #6 | 37.92 us | 52 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #7 | 37.77 us | 52 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #8 | 27.471 ms | 6 MB + 400 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #9 | 27.466 ms | 6 MB + 400 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #10 | 26.683 ms | 6 MB + 132 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #11 | 28.64 ms | 6 MB + 748 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #12 | 25.099 ms | 5 MB + 628 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #13 | 36.79 us | 52 KB | Accepted | Score: 0 | 显示更多 |