// luogu-judger-enable-o2
// luogu-judger-enable-o2
#include<bits/stdc++.h>
using namespace std;
double pi(acos(-1));
struct comp {
double s,x;
inline comp operator+(const comp&b) const {
return(comp) {
s+b.s,x+b.x
};
}
inline comp operator-(const comp&b) const {
return(comp) {
s-b.s,x-b.x
};
}
inline comp operator*(const comp&b) const {
return(comp) {
s*b.s-x*b.x,s*b.x+b.s*x
};
}
comp (double xx=0,double yy=0) {
s=xx,x=yy;
}
} a[3100010];
int n,m;
void DFT(comp a[],int len) {
if(len<=1)return;
comp A0[(len>>1)+1],A1[(len>>1)+1];
for(int i=0; i<=len; i+=2)
A0[i>>1]=a[i],A1[i>>1]=a[i+1];
DFT(A0,len>>1);
DFT(A1,len>>1);
comp w=(comp) {
cos(2.0*pi/len),sin(2.0*pi/len)
};
comp d=(comp) {
1.0,0.0
};
for(int i=0; i<len/2; i++,d=d*w) {
a[i]=A0[i]+A1[i]*d;
a[i+(len>>1)]=A0[i]-A1[i]*d;
}
return;
}
void IDFT(comp a[],int len) {
if(len<=1)return;
comp A0[(len>>1)+1],A1[(len>>1)+1];
for(int i=0; i<=len; i+=2)
A0[i>>1]=a[i],A1[i>>1]=a[i+1] ;
IDFT(A0,len>>1);
IDFT(A1,len>>1);
comp w=(comp) {
cos(2.0*pi/len),sin(2.0*pi/len)*(-1.0)
};
comp d=(comp) {
1.0,0.0
};
for(int i=0; i<len/2; i++,d=d*w) {
a[i]=A0[i]+A1[i]*d;
a[i+(len>>1)]=A0[i]-A1[i]*d;
}
return;
}
long long int p;
int main() {
scanf("%d%d",&n,&m);
for(int i=0; i<=n; i++) {
int x(0);
scanf("%d",&x);
a[i].s=(double)x;
}
for(int i=0; i<=m; i++) {
int x(0);
scanf("%d",&x);
a[i].x=(double)x;
}
int lenth(1);
while(lenth<=n+m+2)lenth=lenth<<1;
DFT(a,lenth);
for(int i=0; i<lenth; i++) {
a[i]=a[i]*a[i];
}
IDFT(a,lenth);
for(int i=0; i<lenth; i++)
a[i].x/=(double)lenth;
for(int i=0; i<=n+m; i++) {
printf("%lld ",(long long)(a[i].x/2.0+0.1));
}
return 0;
}
| Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
| Subtask #1 Testcase #1 | 5.357 ms | 47 MB + 344 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #2 | 85.714 ms | 56 MB + 772 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #3 | 42.413 ms | 51 MB + 624 KB | Accepted | Score: 100 | 显示更多 |
| Subtask #1 Testcase #4 | 42.484 ms | 51 MB + 612 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #5 | 5.312 ms | 47 MB + 344 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #6 | 5.57 ms | 47 MB + 344 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #7 | 5.314 ms | 47 MB + 344 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #8 | 79.486 ms | 56 MB + 504 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #9 | 79.668 ms | 56 MB + 504 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #10 | 73.514 ms | 56 MB + 236 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #11 | 86.052 ms | 56 MB + 852 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #12 | 86.482 ms | 55 MB + 732 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #13 | 5.318 ms | 47 MB + 344 KB | Accepted | Score: 0 | 显示更多 |