// luogu-judger-enable-o2
// luogu-judger-enable-o2
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cctype>
using namespace std;
int n,m;
const long double PI=acos(-1.0);
struct Complex
{
long double x,y;
}a[4200000],b[4200000];
Complex operator + (Complex a,Complex b)
{
return {a.x+b.x,a.y+b.y};
}
Complex operator - (Complex a,Complex b)
{
return {a.x-b.x,a.y-b.y};
}
Complex operator * (Complex a,Complex b)
{
return {a.x*b.x-a.y*b.y,a.x*b.y+a.y*b.x};
}
int lim=1,l,r[4200000];
void FFT(Complex *A,int type)
{
for (int i=0;i<lim;i++)
if (i<r[i])
swap(A[i],A[r[i]]);
for (int mid=1;mid<lim;mid<<=1)
{
Complex Wn={cos(PI/mid),type*sin(PI/mid)};
for (int j=0;j<lim;j+=(mid<<1))
{
Complex W={1,0};
for (int k=0;k<mid;k++)
{
Complex x=A[j+k],y=W*A[j+mid+k];
A[j+k]=x+y;
A[j+mid+k]=x-y;
W=W*Wn;
}
}
}
}
struct io
{
char ibuf[26777259] , * s , obuf[26777259] , * t;
int a[24];
io() : t( obuf )
{
s[ fread( s = ibuf , 1 , 26777259 , stdin ) ] = 0;
}
~io()
{
fwrite( obuf , 1 , t - obuf , stdout );
}
inline int read()
{
register int u = 0;
while( * s < 48 ) s++;
while( * s > 32 )
u = u * 10 + * s++ - 48;
return u;
}
template < class T >
inline void print( register T u )
{
static int * q = a;
if( !u ) * t++ = 48;
else
{
while( u ) * q++ = u % 10 + 48 , u /= 10;
while( q != a )
* t++ = * --q;
}
* t++ = ' ';
}
} ip;
#define read ip.read
#define print ip.print
int main()
{
n=read();m=read();
for (int i=0;i<=n;i++)
a[i].x=read();
for (int i=0;i<=m;i++)
b[i].x=read();
while (lim<=n+m)
{
lim<<=1;
l++;
}
for (int i=0;i<lim;i++)
r[i]=(r[i>>1]>>1)|((i&1)<<(l-1));
FFT(a,1);
FFT(b,1);
for (int i=0;i<=lim;i++)
a[i]=a[i]*b[i];
FFT(a,-1);
for (int i=0;i<=n+m;i++)
print((int)(a[i].x/lim+0.5));
return 0;
}
//苟利国家生死以,岂因祸福避趋之
Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
Subtask #1 Testcase #1 | 0 ns | 0 KB | Memory Limit Exceeded | Score: 0 | 显示更多 |
Subtask #1 Testcase #2 | 0 ns | 0 KB | Memory Limit Exceeded | Score: 0 | 显示更多 |
Subtask #1 Testcase #3 | 0 ns | 0 KB | Memory Limit Exceeded | Score: 0 | 显示更多 |
Subtask #1 Testcase #4 | 0 ns | 0 KB | Memory Limit Exceeded | Score: 0 | 显示更多 |
Subtask #1 Testcase #5 | 0 ns | 0 KB | Memory Limit Exceeded | Score: 0 | 显示更多 |
Subtask #1 Testcase #6 | 0 ns | 0 KB | Memory Limit Exceeded | Score: 0 | 显示更多 |
Subtask #1 Testcase #7 | 0 ns | 0 KB | Memory Limit Exceeded | Score: 0 | 显示更多 |
Subtask #1 Testcase #8 | 0 ns | 0 KB | Memory Limit Exceeded | Score: 0 | 显示更多 |
Subtask #1 Testcase #9 | 0 ns | 0 KB | Memory Limit Exceeded | Score: 0 | 显示更多 |
Subtask #1 Testcase #10 | 0 ns | 0 KB | Memory Limit Exceeded | Score: 0 | 显示更多 |
Subtask #1 Testcase #11 | 0 ns | 0 KB | Memory Limit Exceeded | Score: 0 | 显示更多 |
Subtask #1 Testcase #12 | 0 ns | 0 KB | Memory Limit Exceeded | Score: 0 | 显示更多 |
Subtask #1 Testcase #13 | 0 ns | 0 KB | Memory Limit Exceeded | Score: 0 | 显示更多 |