#include<cstdio>
#include<cmath>
#include<iostream>
using namespace std;
int read(){
int n=0; char c=getchar();
while(c<'0'||c>'9') c=getchar();
while(c>='0'&&c<='9') n=n*10+(c^48), c=getchar();
return n;
}
const int Mx=3e5;
const double Pi=acos(-1);
struct Complex{
double Real,Ima;
Complex operator + (const Complex& a) const { return (Complex){Real+a.Real,Ima+a.Ima};}
Complex operator - (const Complex& a) const { return (Complex){Real-a.Real,Ima-a.Ima};}
Complex operator * (const Complex& a) const { return (Complex){Real*a.Real-Ima*a.Ima,Real*a.Ima+Ima*a.Real};}
Complex operator += (const Complex& a) { return (*this)=(Complex){Real+a.Real,Ima+a.Ima};}
Complex operator -= (const Complex& a) { return (*this)=(Complex){Real-a.Real,Ima-a.Ima};}
Complex operator *= (const Complex& a) { return (*this)=(Complex){Real*a.Real-Ima*a.Ima,Real*a.Ima+Ima*a.Real};}
}F[Mx];
int Rfl[Mx];
void FFT(Complex A[],int Len,int Type){
for(int i=0;i<Len;++i) if(i<Rfl[i]) swap(F[i],F[Rfl[i]]);
for(int i=1;i<Len;i<<=1){
Complex Omiga={cos(Pi/i),sin(Pi/i)*Type};
for(int j=0;j<Len;j+=(i<<1)){
Complex Unit={1.0,0.0};
for(int k=0;k<i;++k, Unit*=Omiga){
Complex A1=A[k+j],A2=A[k+j+i]*Unit;
A[k+j]=A1+A2, A[k+j+i]=A1-A2;
}
}
}
}
int main(){
int n=read(),m=read();
for(int i=0;i<=n;++i) F[i].Real=read();
for(int i=0;i<=m;++i) F[i].Ima=read();
int Len=1,pw=0;
while(Len<=n+m) Len<<=1, ++pw;
for(int i=1;i<Len;++i) Rfl[i]=(i&1)?(Rfl[i-1]+(1<<(pw-1))):Rfl[i>>1]>>1;
FFT(F,Len,1);
for(int i=0;i<Len;++i) F[i]*=F[i];
FFT(F,Len,-1);
for(int i=0;i<=n+m;++i) printf("%d ",(int)(0.5+F[i].Ima/(Len<<1)));
return 0;
}
Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
Subtask #1 Testcase #1 | 34.88 us | 44 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #2 | 50.114 ms | 6 MB + 472 KB | Accepted | Score: 100 | 显示更多 |
Subtask #1 Testcase #3 | 22.874 ms | 2 MB + 836 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #4 | 22.887 ms | 2 MB + 824 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #5 | 36.6 us | 44 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #6 | 36.25 us | 44 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #7 | 35.56 us | 44 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #8 | 44.694 ms | 6 MB + 204 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #9 | 44.835 ms | 6 MB + 204 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #10 | 39.316 ms | 5 MB + 960 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #11 | 50.355 ms | 6 MB + 552 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #12 | 50.354 ms | 5 MB + 432 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #13 | 34.02 us | 44 KB | Accepted | Score: 0 | 显示更多 |