#include <cstdio>
#include <cctype>
#include <algorithm>
#include <cmath>
namespace fastIO {
const int SZ = 1 << 25;
char ibuf[SZ], *p0 = ibuf, *p1 = ibuf;
inline char getchar(void) { return p0 == p1 && (p1 = (p0 = ibuf) + fread(ibuf, 1, SZ, stdin), p0 == p1) ? EOF : *p0++; }
char char_read; void read(auto &val) {
val = 0; do char_read = getchar(); while(!isdigit(char_read));
do val = val * 10 + char_read - '0'; while(isdigit(char_read = getchar()));
}
char obuf[SZ], *p = obuf;
inline void putchar(char char_write) { *p++ = char_write; }
void write(auto val) { if(val >= 10) write(val / 10); putchar(val % 10 + '0'); }
inline void write(auto a[], int sz) { for(int i = 0; i < sz; ++i) write(a[i]), putchar(' '); putchar('\n'); }
void output(void) { fwrite(obuf, p - obuf, 1, stdout);}
};
const int N = 1 << 21;
const int p = (13 << 23) - 1;
int pow_modp(int a, int b) { int x = 1; for(; b; a = (long long)a * a % p, b >>= 1) if(b & 1) x = (long long)x * a % p; return x; }
struct CMPLX {
int real, imag;
CMPLX operator + (const CMPLX z) const { return { real + z.real < 0 ? real + z.real + p : real + z.real - p, imag + z.imag < 0 ? imag + z.imag + p : imag + z.imag - p }; }
CMPLX operator - (const CMPLX z) const { return { real - z.real < 0 ? real - z.real + p : real - z.real - p, imag - z.imag < 0 ? imag - z.imag + p : imag - z.imag - p }; }
CMPLX operator * (const CMPLX z) const { return { ((long long)real * z.real - (long long)imag * z.imag) % p, ((long long)real * z.imag + (long long)imag * z.real) % p }; }
void operator *= (const CMPLX z) {
auto t = ((long long)real * z.real - (long long)imag * z.imag) % p;
imag = ((long long)real * z.imag + (long long)imag * z.real) % p; real = t;
return;
}
};
CMPLX pow_modp(CMPLX a, int b) { CMPLX x = {1, 0}; for(; b; a = a * a, b >>= 1) if(b & 1) x = x * a; return x; }
#define w(n) pow_modp({20747, +2402}, (p + 1) / n)
#define v(n) pow_modp({20747, -2402}, (p + 1) / n)
CMPLX fft_sup[N];
void fft(auto a[], int n, CMPLX w) {
auto fft_a = fft_sup; for(int i = 1; i < n; i <<= 1, w = w * w, std :: swap(a, fft_a)) {
auto _w = (CMPLX){1, 0}; for(auto k0 = fft_a, j0 = a, j1 = a + (n >> 1); k0 != fft_a + n; k0 += i, _w = _w * w)
for(auto k1 = k0 + i, _k0 = k1; k0 != _k0; ++j0, ++j1, ++k0, ++k1)
*k0 = *j0 + *j1,
k1->real = ((long long)(j0->real - j1->real) * _w.real - (long long)(j0->imag - j1->imag) * _w.imag) % p,
k1->imag = ((long long)(j0->real - j1->real) * _w.imag + (long long)(j0->imag - j1->imag) * _w.real) % p;
}
if(fft_a != fft_sup) std :: copy(a, a + n, fft_a);
}
void poly_mul(auto a[], auto b[], int n) {
fft(a, n, w(n)), fft(b, n, w(n)); for(int i = 0; i < n; ++i) a[i] = a[i] * b[i]; fft(a, n, v(n));
int inv_n = pow_modp(n, p - 2); for(int i = 0; i < n; ++i) a[i].real = (long long)a[i].real * inv_n % p;
}
int n, n_a, n_b;
CMPLX a[N], b[N];
int ans[N];
int main(void) {
fastIO :: read(n_a), fastIO :: read(n_b); ++n_a, ++n_b; for(n = 1; n < n_a + n_b; n <<= 1);
for(int i = 0, t; i < n_a; ++i) fastIO :: read(t), a[i].real = t;
for(int i = 0, t; i < n_b; ++i) fastIO :: read(t), b[i].real = t;
poly_mul(a, b, n); n = n_a + n_b - 1;
for(int i = 0; i < n; ++i) ans[i] = a[i].real < 0 ? a[i].real + p : a[i].real;
fastIO :: write(ans, n), fastIO :: output();
return 0;
}
| Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
| Subtask #1 Testcase #1 | 8.44 us | 36 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #2 | 37.751 ms | 10 MB + 12 KB | Accepted | Score: 100 | 显示更多 |
| Subtask #1 Testcase #3 | 16.924 ms | 4 MB + 156 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #4 | 16.968 ms | 4 MB + 136 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #5 | 8.25 us | 36 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #6 | 9.27 us | 36 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #7 | 9.06 us | 36 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #8 | 36.908 ms | 9 MB + 300 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #9 | 36.949 ms | 9 MB + 300 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #10 | 36.114 ms | 8 MB + 588 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #11 | 37.984 ms | 10 MB + 176 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #12 | 34.774 ms | 7 MB + 956 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #13 | 8.3 us | 36 KB | Accepted | Score: 0 | 显示更多 |