#include<bits/stdc++.h>
using namespace std;
const int N=21e5+3;
const double P=acos(-1);
struct C{
double x,y;
C operator+(C a)const{return{x+a.x,y+a.y};}
C operator-(C a)const{return{x-a.x,y-a.y};}
C operator*(C a)const{return{x*a.x-y*a.y,x*a.y+y*a.x};}
}a[N],g[N];
int n,r[N];
void fft(C*a){
int i,j,k;
C *w,*u,*v,x;
for(i=0;i<n;++i)if(i<r[i])swap(a[i],a[r[i]]);
for(i=1;i<n;i<<=1)for(j=0;j<n;j+=i<<1)for(k=0,w=g+i,u=a+j,v=u+i;k<i;++k)
x=w[k]*v[k],v[k]=u[k]-x,u[k]=u[k]+x;
}
char buf[999999],*p1,*p2;
#define G (p1==p2?(p2=(p1=buf)+fread(buf,1,999991,stdin),*p1++):*p1++)
void in(int&x){char c=G;for(x=0;c<'0'||c>'9';c=G);for(;c>='0'&&c<='9';c=G)x=x*10+c-48;}
char c2[999999],st[13],*k3=c2,*k4;
void out(int x){
if(!x){
*k3++=48,*k3++=' ';
return;
}
for(k4=st+1,*k4=' ';x;*++k4=x%10+48,x/=10);
for(;k4!=st;*k3++=*k4--);
}
int main(){
int m,i,j;
double o;
scanf("%d%d",&n,&m);
for(i=0;i<=n;++i)in(j),a[i].x=j;
for(i=0;i<=m;++i)in(j),a[i].y=j;
for(m+=n,n=1;n<=m;n<<=1);
for(i=0,g[j=n>>1]={1,0};i<n;++i)r[i]=(r[i>>1]>>1)|((i&1)?j:0);
C w={cos(2*P/n),sin(2*P/n)};
for(i=j+1;i<n;++i)g[i]=g[i-1]*w;
for(i=j-1;i>0;--i)g[i]=g[i<<1];
fft(a);
for(i=0;i<n;++i)a[i]=a[i]*a[i];
fft(a),a[n]=a[0],o=1.0/n/2;
for(i=0;i<=m;++i)out(a[n-i].y*o+0.5);
fwrite(c2,1,k3-c2,stdout);
return 0;
}
Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
Subtask #1 Testcase #1 | 36.92 us | 56 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #2 | 23.264 ms | 11 MB + 912 KB | Accepted | Score: 100 | 显示更多 |
Subtask #1 Testcase #3 | 8.87 ms | 5 MB + 300 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #4 | 8.965 ms | 5 MB + 280 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #5 | 38.11 us | 56 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #6 | 36.59 us | 56 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #7 | 36.04 us | 56 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #8 | 22.28 ms | 11 MB + 488 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #9 | 22.27 ms | 11 MB + 488 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #10 | 21.249 ms | 11 MB + 96 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #11 | 23.556 ms | 12 MB + 48 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #12 | 19.129 ms | 10 MB + 200 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #13 | 36.12 us | 56 KB | Accepted | Score: 0 | 显示更多 |