#include<algorithm>
#include<cmath>
#include<cstdio>
#include<iostream>
static char ibuf[1<<20|1], *p1 = ibuf, *p2 = ibuf;
struct IO {
char gc() {
return p1 == p2 && (p2 = (p1 = ibuf) + fread(ibuf, 1, 1 << 20 | 1, stdin)) ? EOF : *p1++;
}
template<typename T>
IO operator>>(T &n) {
n = 0; char c = gc();
while (c < '0' || c > '9') c = gc();
while (c >= '0' && c <= '9') n = n * 10 + (c ^ 48), c = gc();
return *this;
}
} cin;
struct Complex {
double x, y;
Complex() {}
Complex(double X, double Y): x(X), y(Y) {}
Complex operator+(Complex rhs) {
return Complex(x + rhs.x, y + rhs.y);
}
Complex operator-(Complex rhs) {
return Complex(x - rhs.x, y - rhs.y);
}
Complex operator*(Complex rhs) {
return Complex(x * rhs.x - y * rhs.y, x * rhs.y + y * rhs.x);
}
} F[1<<21|1];
constexpr double pi = acos(-1.);
int to[1<<21|1];
void FFT(int N, Complex *a, int type) {
for (int i = 0; i < N; ++i)
if (i < to[i]) std::swap(a[i], a[to[i]]);
Complex rt, w, t1, t2;
for (int m = 1; m < N; m <<= 1) {
rt = Complex(cos(pi / m), type * sin(pi / m));
for (int j = 0; j < N; j += m << 1) {
w = Complex(1, 0);
for (int k = 0; k < m; ++k, w = w * rt) {
t1 = a[j | k], t2 = w * a[j | k | m];
a[j | k] = t1 + t2, a[j | k | m] = t1 - t2;
}
}
}
if (type == -1)
for (int i = 0; i < N; ++i)
a[i].x /= N, a[i].y /= N;
}
int main() {
int N, M, lim, l;
cin >> N >> M;
for (lim = 1, l = -1; lim <= N + M; lim <<= 1, ++l);
for (int i = 0; i < lim; ++i)
to[i] = (to[i >> 1] >> 1) | ((i & 1) << l);
for (int i = 0, t; i <= N; ++i)
cin >> t, F[i].x = t;
for (int i = 0, t; i <= M; ++i)
cin >> t, F[i].y = t;
FFT(lim, F, 1);
for (int i = 0; i < lim; ++i)
F[i] = F[i] * F[i];
FFT(lim, F, -1);
for (int i = 0; i <= N + M; ++i)
std::cout << int(F[i].y / 2 + 0.5) << ' ';
return 0;
}
| Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
| Subtask #1 Testcase #1 | 35.84 us | 48 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #2 | 39.825 ms | 6 MB + 864 KB | Accepted | Score: 100 | 显示更多 |
| Subtask #1 Testcase #3 | 18.033 ms | 3 MB + 12 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #4 | 18.026 ms | 3 MB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #5 | 37.62 us | 48 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #6 | 35.77 us | 48 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #7 | 35.15 us | 48 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #8 | 36.384 ms | 6 MB + 532 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #9 | 36.366 ms | 6 MB + 532 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #10 | 33.032 ms | 6 MB + 196 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #11 | 40.16 ms | 6 MB + 944 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #12 | 36.686 ms | 5 MB + 824 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #13 | 34.22 us | 48 KB | Accepted | Score: 0 | 显示更多 |