#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
inline int read() {
int x = 0, f = 1;
char ch = getchar();
while (ch < '0' || ch > '9') {
if (ch == '-') f = -1;
ch = getchar();
}
while (ch <= '9' && ch >= '0') {
x = 10 * x + ch - '0';
ch = getchar();
}
return x * f;
}
void print(int x) {
if (x < 0) putchar('-'), x = -x;
if (x >= 10) print(x / 10);
putchar(x % 10 + '0');
}
const int N = 1 << 21, P = 998244353;
inline int qpow(int x, int y) {
int res(1);
while (y) {
if (y & 1) res = 1ll * res * x % P;
x = 1ll * x * x % P;
y >>= 1;
}
return res;
}
int r[N];
void ntt(int *x, int lim, int opt) {
register int i, j, k, m, gn, g, tmp;
for (i = 0; i < lim; ++i)
if (r[i] < i) swap(x[i], x[r[i]]);
for (m = 2; m <= lim; m <<= 1) {
k = m >> 1;
gn = qpow(3, (P - 1) / m);
for (i = 0; i < lim; i += m) {
g = 1;
for (j = 0; j < k; ++j, g = 1ll * g * gn % P) {
tmp = 1ll * x[i + j + k] * g % P;
x[i + j + k] = (x[i + j] - tmp + P) % P;
x[i + j] = (x[i + j] + tmp) % P;
}
}
}
if (opt == -1) {
reverse(x + 1, x + lim);
register int inv = qpow(lim, P - 2);
for (i = 0; i < lim; ++i) x[i] = 1ll * x[i] * inv % P;
}
}
int A[N], B[N], C[N];
int n, n_a, n_b;
int main(void) {
scanf("%d%d", &n_a, &n_b); for(n = 1; n <= n_a + n_b; n <<= 1);
for(int i = 0; i <= n_a; ++i) scanf("%d", A + i);
for(int i = 0; i <= n_b; ++i) scanf("%d", B + i);
for(int i = 0; i < n; ++i) r[i] = (i & 1) * (n >> 1) + (r[i >> 1] >> 1);
ntt(A, n, 1); ntt(B, n, 1);
for(int i = 0; i < n; ++i) C[i] = 1ll * A[i] * B[i] % P;
ntt(C, n, -1);
for(int i = 0; i <= n_a + n_b; ++i) printf("%d ", C[i]);
return 0;
}
| Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
| Subtask #1 Testcase #1 | 36.72 us | 52 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #2 | 75.15 ms | 5 MB + 480 KB | Accepted | Score: 100 | 显示更多 |
| Subtask #1 Testcase #3 | 34.755 ms | 2 MB + 332 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #4 | 34.805 ms | 2 MB + 320 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #5 | 39.1 us | 52 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #6 | 37.48 us | 52 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #7 | 37.33 us | 52 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #8 | 69.341 ms | 5 MB + 212 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #9 | 69.233 ms | 5 MB + 212 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #10 | 63.564 ms | 4 MB + 968 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #11 | 75.125 ms | 5 MB + 560 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #12 | 75.289 ms | 4 MB + 440 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #13 | 35.44 us | 52 KB | Accepted | Score: 0 | 显示更多 |