#include<cstdio>
#include<algorithm>
#include<ctype.h>
#include<string.h>
#include<math.h>
using namespace std;
#define ll long long
#define travel(i,x) for(int i=h[x];i;i=pre[i])
inline char read() {
static const int IN_LEN = 1000000;
static char buf[IN_LEN], *s, *t;
return (s == t ? t = (s = buf) + fread(buf, 1, IN_LEN, stdin), (s == t ? -1 : *s++) : *s++);
}
template<class T>
inline void read(T &x) {
static bool iosig;
static char c;
for (iosig = false, c = read(); !isdigit(c); c = read()) {
if (c == '-') iosig = true;
if (c == -1) return;
}
for (x = 0; isdigit(c); c = read()) x = ((x + (x << 2)) << 1) + (c ^ '0');
if (iosig) x = -x;
}
const int OUT_LEN = 10000000;
char obuf[OUT_LEN], *ooh = obuf;
inline void print(char c) {
if (ooh == obuf + OUT_LEN) fwrite(obuf, 1, OUT_LEN, stdout), ooh = obuf;
*ooh++ = c;
}
template<class T>
inline void print(T x) {
static int buf[30], cnt;
if (x == 0) print('0');
else {
if (x < 0) print('-'), x = -x;
for (cnt = 0; x; x /= 10) buf[++cnt] = x % 10 + 48;
while (cnt) print((char)buf[cnt--]);
}
}
inline void flush() { fwrite(obuf, 1, ooh - obuf, stdout); }
const double pi = acos(-1);
const int N = 1<<18;
int n, m, p;
struct cp{
double a, b;
inline cp operator +(const cp &rhs)const{ return (cp){a+rhs.a, b+rhs.b};}
inline cp operator -(const cp &rhs)const{ return (cp){a-rhs.a, b-rhs.b};}
inline cp operator *(const cp &rhs)const{ return (cp){a*rhs.a-b*rhs.b, a*rhs.b+b*rhs.a};}
inline cp operator *(const double rhs)const{ return (cp){a*rhs, b*rhs};}
}a[N], b[N];
inline void FFT(cp *f, int g){
for(int i=0, j=0; i<p; ++i){
if(i>j) swap(f[i], f[j]);
for(int k=p>>1; (j^=k)<k; k>>=1);
}
for(int i=2; i<=p; i<<=1){
int tmp=i>>1;
register cp w0=(cp){cos(2*pi/i), g*sin(2*pi/i)};
for(int j=0; j<p; j+=i){
register cp w=(cp){1, 0};
for(int k=j; k<j+tmp; ++k){
register cp t=f[k+tmp]*w;
f[k+tmp]=f[k]-t;
f[k]=f[k]+t;
w=w*w0;
}
}
}
}
int main() {
read(n), read(m), ++n, ++m;
for(int i=0; i<n; ++i){static int tmp; read(tmp); a[i].a=tmp;}
for(int i=0; i<m; ++i){static int tmp; read(tmp); b[i].a=tmp;}
for(p=1; p<n+m-1; p<<=1);
FFT(a, 1), FFT(b, 1);
for(int i=0; i<p; ++i) a[i]=a[i]*b[i];
FFT(a, -1);
for(int i=0; i<n+m-1; ++i) print((int)(a[i].a/p+0.5)), print(' ');
return flush(), 0;
}
| Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
| Subtask #1 Testcase #1 | 7.99 us | 32 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #2 | 36.483 ms | 11 MB + 248 KB | Accepted | Score: 100 | 显示更多 |
| Subtask #1 Testcase #3 | 15.118 ms | 4 MB + 788 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #4 | 15.26 ms | 4 MB + 768 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #5 | 8.31 us | 32 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #6 | 8.96 us | 32 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #7 | 8.04 us | 32 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #8 | 35.539 ms | 10 MB + 668 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #9 | 35.599 ms | 10 MB + 668 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #10 | 34.691 ms | 10 MB + 64 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #11 | 36.807 ms | 11 MB + 412 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #12 | 33.018 ms | 9 MB + 168 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #13 | 7.81 us | 32 KB | Accepted | Score: 0 | 显示更多 |