#include<stdio.h>
#include<math.h>
#include<algorithm>
using namespace std;
const double pi=3.1415926535897932384626433832795;
struct c
{
double r,i;
inline c(){r=i=0.0;}
inline c(const double a,const double b){r=a,i=b;}
inline c operator+(const c &x)const{return c(r+x.r,i+x.i);}
inline c operator+=(const c &x){return *this=*this+x;}
inline c operator-(const c &x)const{return c(r-x.r,i-x.i);}
inline c operator-=(const c &x){return *this=*this-x;}
inline c operator*(const c &x)const{return c(r*x.r-i*x.i,r*x.i+i*x.r);}
inline c operator*=(const c &x){return *this=*this*x;}
inline c operator/=(const int x){r/=x,i/=x;return *this;}
inline c conj(){return c(r,-i);}
}A[277777];
int r[277777],l=1;
int n,m;
inline void fft(c *a,int ty)
{
for(int i=0;i<l;i++)i<r[i]?(void)(0):swap(a[i],a[r[i]]);
for(int i=1;i<l;i<<=1)
{
c w(cos(pi/i),ty*sin(pi/i));
for(int j=0;j<l;j+=i<<1)
{
c wn(1.0,0.0);
for(int k=j;k<i+j;k++)
{
c t=a[i+k]*wn;
a[i+k]=a[k]-t;
a[k]+=t;
wn*=w;
}
}
}
}
int main()
{
scanf("%d",&n);
scanf("%d",&m);
for(int i=0;i<=n;i++)scanf("%lf",&A[i].r);
for(int i=0;i<=m;i++)scanf("%lf",&A[i].i);
while(l<=n+m)l<<=1;
for(int i=1;i<l;i<<=1)
for(int j=0;j<i;j++)
r[i+j]=r[j]+l/(i<<1);
fft(A,1);
A[l]=A[0];
for(int i=0;i<=l-i;i++)
{
c t=(A[i]+A[l-i].conj())*c(0.0,1.0)*(A[i]-A[l-i].conj());t/=4;
c t2=(A[l-i]+A[i].conj())*c(0.0,1.0)*(A[l-i]-A[i].conj());t2/=4;
A[i]=t;A[l-i]=t2;
}
fft(A,-1);
for(int i=0;i<=n+m;i++)printf("%d ",int(-A[i].r/l+0.5));
return 0;
}
Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
Subtask #1 Testcase #1 | 479.34 us | 4 MB + 272 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #2 | 56.809 ms | 6 MB + 700 KB | Accepted | Score: 100 | 显示更多 |
Subtask #1 Testcase #3 | 25.927 ms | 5 MB + 40 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #4 | 25.978 ms | 5 MB + 28 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #5 | 479.68 us | 4 MB + 272 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #6 | 480.39 us | 4 MB + 272 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #7 | 472.24 us | 4 MB + 272 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #8 | 50.49 ms | 6 MB + 432 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #9 | 50.612 ms | 6 MB + 432 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #10 | 44.436 ms | 6 MB + 164 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #11 | 56.967 ms | 6 MB + 780 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #12 | 56.99 ms | 5 MB + 660 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #13 | 479.36 us | 4 MB + 272 KB | Accepted | Score: 0 | 显示更多 |