#include<cstdio>
#include<algorithm>
#include<ctype.h>
#include<string.h>
#include<math.h>
using namespace std;
#define ll long long
#define travel(i,x) for(int i=h[x];i;i=pre[i])
inline char read() {
static const int IN_LEN = 1000000;
static char buf[IN_LEN], *s, *t;
return (s == t ? t = (s = buf) + fread(buf, 1, IN_LEN, stdin), (s == t ? -1 : *s++) : *s++);
}
template<class T>
inline void read(T &x) {
static bool iosig;
static char c;
for (iosig = false, c = read(); !isdigit(c); c = read()) {
if (c == '-') iosig = true;
if (c == -1) return;
}
for (x = 0; isdigit(c); c = read()) x = ((x + (x << 2)) << 1) + (c ^ '0');
if (iosig) x = -x;
}
const int OUT_LEN = 10000000;
char obuf[OUT_LEN], *ooh = obuf;
inline void print(char c) {
if (ooh == obuf + OUT_LEN) fwrite(obuf, 1, OUT_LEN, stdout), ooh = obuf;
*ooh++ = c;
}
template<class T>
inline void print(T x) {
static int buf[30], cnt;
if (x == 0) print('0');
else {
if (x < 0) print('-'), x = -x;
for (cnt = 0; x; x /= 10) buf[++cnt] = x % 10 + 48;
while (cnt) print((char)buf[cnt--]);
}
}
inline void flush() { fwrite(obuf, 1, ooh - obuf, stdout); }
const int N = 1<<18, P = 998244353;
int n, m, p, a[N], b[N], w[N];
inline ll Pow(ll x, register int y=P-2) {
ll ass=1;
for(; y; y>>=1, x=x*x%P) if(y&1) ass=ass*x%P;
return ass;
}
inline int Mod(int x){ return x<P?x:x-P;}
inline void NTT(int *f, int g){
for(int i=0, j=0; i<p; ++i){
if(i>j) swap(f[i], f[j]);
for(int k=p>>1; (j^=k)<k; k>>=1);
}
for(int i=1; i<p; i<<=1){
w[0]=1;
for(int j=1, w0=(g==1?Pow(3, (P-1)/i/2):Pow(Pow(3, (P-1)/i/2))); j<i; ++j) w[j]=(ll)w[j-1]*w0%P;
for(int j=0; j<p; j+=i<<1){
for(int k=j; k<j+i; ++k){
int t=(ll)f[k+i]*w[k-j]%P;
f[k+i]=Mod(f[k]-t+P);
f[k]=Mod(f[k]+t);
}
}
}
}
int main() {
read(n), read(m), ++n, ++m;
for(int i=0; i<n; ++i) read(a[i]);
for(int i=0; i<m; ++i) read(b[i]);
for(p=1; p<n+m-1; p<<=1);
NTT(a, 1), NTT(b, 1);
for(int i=0; i<p; ++i) a[i]=(ll)a[i]*b[i]%P;
NTT(a, -1);
for(int i=0, I=Pow(p); i<n+m-1; ++i) print((ll)a[i]*I%P), print(' ');
return flush(), 0;
}
| Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
| Subtask #1 Testcase #1 | 8.88 us | 36 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #2 | 28.932 ms | 5 MB + 764 KB | Accepted | Score: 100 | 显示更多 |
| Subtask #1 Testcase #3 | 12.486 ms | 2 MB + 24 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #4 | 12.58 ms | 2 MB + 4 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #5 | 9.69 us | 36 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #6 | 8.83 us | 36 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #7 | 8.34 us | 36 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #8 | 27.839 ms | 5 MB + 160 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #9 | 27.819 ms | 5 MB + 160 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #10 | 26.758 ms | 4 MB + 580 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #11 | 29.702 ms | 5 MB + 928 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #12 | 25.216 ms | 3 MB + 684 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #13 | 7.57 us | 36 KB | Accepted | Score: 0 | 显示更多 |