#include <bits/stdc++.h>
struct IO {
const static int S = 1e8;
char buc_in[S], buc_out[S],
*p_in = buc_in, *p_out = buc_out;
IO() {
// freopen("data", "r", stdin);
fread(buc_in, 1, S, stdin);
}
~IO() { fwrite(buc_out, 1, p_out - buc_out, stdout); }
inline int rd() {
int b = 0;
while (!isdigit(*p_in)) ++p_in;
while (isdigit(*p_in)) b = b * 10 + *p_in++ - '0';
return b;
}
inline void out(int x) {
static char buc[10], *p = buc;
do *p++ = x % 10 + '0';
while (x /= 10);
while (p != buc)
*p_out++ = *--p;
*p_out++ = ' ';
}
} io;
const int N = 3e5 + 233, P = 998244353;
inline int fpow(int x, int y) {
int ret = 1;
for ( ; y; y >>= 1, x = 1ll * x * x % P)
if (y & 1) ret = 1ll * ret * x % P;
return ret;
}
const int Gp = 3, Gpi = fpow(Gp, P - 2);
int rev[N], lim, L, inv_lim, w[N];
inline void init(int n) {
L = 0, lim = 1;
while (lim < n) lim <<= 1, ++L;
int omega = fpow(Gp, (P - 1) / lim);
w[0] = 1;
for (int i = 1; i < lim; ++i) {
rev[i] = (rev[i >> 1] >> 1) | ((i & 1) << (L - 1));
w[i] = 1ll * w[i - 1] * omega % P;
}
inv_lim = fpow(lim, P - 2);
}
inline void DFT(int f[], int o) {
static unsigned long long tmp[N];
for (int i = 0; i < lim; ++i)
tmp[rev[i]] = f[i];
for (int i = 0; i < lim; i += 2) {
int nx = tmp[i], ny = tmp[i + 1];
tmp[i] = nx + ny, tmp[i + 1] = nx + P - ny;
}
for (int i = 2; i < lim; i <<= 1) {
for (int j = 0; j < lim; j += i << 1) {
auto *a = tmp + j, *b = tmp + i + j;
auto *p = w;
for (int k = 0; k < i; ++k, p += lim / (i << 1)) {
int ny = b[k] * *p % P;
b[k] = a[k] + P - ny;
a[k] += ny;
}
}
}
for (int i = 0; i < lim; ++i)
f[i] = tmp[i] % P;
if (o == -1) {
std::reverse(f + 1, f + lim);
for (int i = 0; i < lim; ++i)
f[i] = 1ll * f[i] * inv_lim % P;
}
}
int n, m, A[N], B[N];
int main() {
n = io.rd(), m = io.rd();
for (int i = 0; i <= n; ++i)
A[i] = io.rd();
for (int i = 0; i <= m; ++i)
B[i] = io.rd();
init(n + m + 1);
DFT(A, 1), DFT(B, 1);
for (int i = 0; i < lim; ++i)
A[i] = 1ll * A[i] * B[i] % P;
DFT(A, -1);
for (int i = 0; i <= n + m; ++i)
io.out(A[i]);
return 0;
}
Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
Subtask #1 Testcase #1 | 36.16 us | 64 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #2 | 28.176 ms | 9 MB + 288 KB | Accepted | Score: 100 | 显示更多 |
Subtask #1 Testcase #3 | 9.149 ms | 3 MB + 816 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #4 | 9.155 ms | 3 MB + 796 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #5 | 38.7 us | 64 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #6 | 36.34 us | 64 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #7 | 36.89 us | 64 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #8 | 27.224 ms | 8 MB + 704 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #9 | 27.225 ms | 8 MB + 704 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #10 | 26.254 ms | 8 MB + 104 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #11 | 28.438 ms | 9 MB + 448 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #12 | 24.209 ms | 7 MB + 204 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #13 | 35.37 us | 64 KB | Wrong Answer | Score: -100 | 显示更多 |