#define DREP(i, s, e) for(int i(s), end_##i(e); i >= end_##i ;i--)
#define REP(i, s, e) for(int i(s), end_##i(e); i <= end_##i ;i++)
#define DEBUG fprintf(stderr, "Passing [%s] in Line %d\n", __FUNCTION__, __LINE__)
#define chkmax(a, b) a = max(a, b)
#define chkmin(a, b) a = min(a, b)
#include <iostream>
#include <cstdio>
using namespace std;
const int maxlen = (1e5 + 1e5 + 10) * 2;
const int MOD = 998244353, gg = 3;
//const int MOD = 469762049, gg = 7;
char buf[maxlen + 5], *p = buf;
#define Getchar() (*p++)
int power_pow(long long base, int b)
{
long long ans(1);
while (b)
{
if (b & 1) (ans *= base) %= MOD;
(base *= base) %= MOD;
b >>= 1;
}
return ans;
}
#define inv(x) power_pow(x, MOD - 2)
int n, m, k;
inline void write(const int x) {if (x / 10) write(x / 10);putchar(x % 10 + '0');}
int L, len, *R, *f, *g;
inline void NTT(int a[], int flag)
{
REP(i, 1, len - 1)
if (i < R[i]) swap(a[i], a[R[i]]);
if (flag > 0)
for (register int i = 1; i < len; i <<= 1)
{
const int wn = power_pow(gg, (MOD - 1) / (i << 1));
for (register int k = 0; k < len; k += i << 1)
{
long long w(1);
for (register int l(0); l < i; l++, (w *= wn) %= MOD)
{
const register int x(a[k + l]), y(w * a[k + l + i] % MOD);
a[k + l] = (x + y) % MOD;
a[k + l + i] = (x - y) % MOD;
}
}
}
else
for (register int i = 1; i < len; i <<= 1)
{
const int wn = inv(power_pow(gg, (MOD - 1) / (i << 1)));
for (register int k = 0; k < len; k += i << 1)
{
long long w(1);
for (register int l(0); l < i; l++, (w *= wn) %= MOD)
{
const register int x(a[k + l]), y(w * a[k + l + i] % MOD);
a[k + l] = (x + y) % MOD;
a[k + l + i] = (x - y) % MOD;
}
}
}
if (flag < 0)
{
static const int invN = inv(len);
REP(i, 0, len - 1) a[i] = 1ll * a[i] * invN % MOD;
}
}
signed main()
{
#ifdef CraZYali
freopen("NTT.in", "r", stdin);
freopen("NTT.out", "w", stdout);
#endif
fread(buf, 1, maxlen, stdin);
char c;
while (isdigit(c = Getchar())) n = n * 10 + c - 48;
while (isdigit(c = Getchar())) m = m * 10 + c - 48;
L = 1;
while ((1 << L) <= n + m) L++;
len = 1 << L;
R = new int[len];R[0] = 0;
f = new int[len];
g = new int[len];
REP(i, 1, len - 1) R[i] = (R[i >> 1] >> 1) | ((i & 1) << L-1);
REP(i, 0, n) f[i] = Getchar() ^ 48, Getchar();
REP(i, 0, m) g[i] = Getchar() ^ 48, Getchar();
REP(i, n + 1, len - 1) f[i] = 0 ;
REP(i, m + 1, len - 1) g[i] = 0 ;
NTT(f, 1);NTT(g, 1);
REP(i, 0, len-1) f[i] = 1ll * f[i] * g[i] % MOD;
NTT(f, -1);
REP(i, 0, n + m) write((f[i] + MOD) % MOD), putchar(' ');
return 0;
}
Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
Subtask #1 Testcase #1 | 35.29 us | 40 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #2 | 47.37 ms | 4 MB + 856 KB | Accepted | Score: 100 | 显示更多 |
Subtask #1 Testcase #3 | 19.708 ms | 2 MB + 4 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #4 | 19.8 ms | 1 MB + 1016 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #5 | 38.58 us | 40 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #6 | 37.61 us | 40 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #7 | 36.07 us | 40 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #8 | 45.579 ms | 4 MB + 524 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #9 | 45.551 ms | 4 MB + 524 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #10 | 43.771 ms | 4 MB + 188 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #11 | 48.562 ms | 4 MB + 936 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #12 | 39.745 ms | 3 MB + 816 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #13 | 35.62 us | 40 KB | Accepted | Score: 0 | 显示更多 |