#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
const double pi=acos(-1);
int n,m,len=1,deg=0;
struct Complex{
double real,imag;
}f[3000010],buf1,buf2;
Complex operator ~(const Complex &x){
return (Complex){x.real,-x.imag};
}
Complex operator -(const Complex &x){
return (Complex){-x.real,-x.imag};
}
Complex operator +(const Complex &x,const Complex &y){
return (Complex){x.real+y.real,x.imag+y.imag};
}
Complex operator -(const Complex &x,const Complex &y){
return (Complex){x.real-y.real,x.imag-y.imag};
}
Complex operator *(const Complex &x,const Complex &y){
return (Complex){x.real*y.real-x.imag*y.imag,x.real*y.imag+x.imag*y.real};
}
Complex operator /(const Complex &x,const Complex &y){
return (Complex){(x.real*y.real+x.imag*y.imag)/(y.real*y.real+y.imag*y.imag),(x.imag*y.real-x.real*y.imag)/(y.real*y.real+y.imag*y.imag)};
}
int main(){
scanf("%d %d",&n,&m);
for(int i=0;i<=n;i++){
scanf("%lf",&f[i].real);
}
for(int i=0;i<=m;i++){
scanf("%lf",&f[i].imag);
}
while(len<=n+m){
len*=2;
deg++;
}
for(int i=0;i<len;i++){
int rev=0;
for(int j=0;j<deg;j++){
if(i&(1<<j)){
rev+=1<<(deg-1-j);
}
}
if(i<rev){
swap(f[i],f[rev]);
}
}
for(int i=0;i<deg;i++){
for(int l1=0;l1<len;l1+=1<<(i+1)){
Complex omega=(Complex){cos(pi/(1<<i)),sin(pi/(1<<i))},pre=(Complex{1,0});
int l2=l1+(1<<i);
for(int j=0;j<(1<<i);j++){
buf1=f[l1+j]+(~pre)*f[l2+j];
buf2=f[l1+j]+(~(-pre))*f[l2+j];
f[l1+j]=buf1;
f[l2+j]=buf2;
pre=pre*omega;
}
}
}
for(int i=0;i<len;i++){
f[i]=f[i]*f[i];
}
for(int i=0;i<len;i++){
int rev=0;
for(int j=0;j<deg;j++){
if(i&(1<<j)){
rev+=1<<(deg-1-j);
}
}
if(i<rev){
swap(f[i],f[rev]);
}
}
for(int i=0;i<deg;i++){
for(int l1=0;l1<len;l1+=1<<(i+1)){
Complex omega=(Complex){cos(pi/(1<<i)),-sin(pi/(1<<i))},pre=(Complex{1,0});
int l2=l1+(1<<i);
for(int j=0;j<(1<<i);j++){
buf1=f[l1+j]+(~pre)*f[l2+j];
buf2=f[l1+j]+(~(-pre))*f[l2+j];
f[l1+j]=buf1;
f[l2+j]=buf2;
pre=pre*omega;
}
}
}
for(int i=0;i<=n+m;i++){
printf("%lld ",(long long)(f[i].imag/len/2+0.5));
}
return 0;
}
| Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
| Subtask #1 Testcase #1 | 46.1 us | 48 KB | Accepted | Score: 100 | 显示更多 |
| Subtask #1 Testcase #2 | 114.928 ms | 5 MB + 476 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #3 | 53.898 ms | 2 MB + 328 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #4 | 53.829 ms | 2 MB + 316 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #5 | 39.54 us | 48 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #6 | 37.6 us | 48 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #7 | 38.08 us | 48 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #8 | 108.562 ms | 5 MB + 208 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #9 | 108.54 ms | 5 MB + 208 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #10 | 102.27 ms | 4 MB + 964 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #11 | 115.302 ms | 5 MB + 556 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #12 | 115.099 ms | 4 MB + 436 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #13 | 37.24 us | 48 KB | Accepted | Score: 0 | 显示更多 |