#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#define UP(i, s, e) for(auto i=s; i!=e; ++i)
namespace m{ // }
using ll = long long;
constexpr double pi = 3.1415926535897932;
constexpr int MOD = 998244353;
struct CC{
int x;
CC(int y=0){x=y;}
CC& operator=(CC b){ x=b.x; return *this; }
CC& operator=(int b){ x=b%MOD; return *this; }
CC operator+(CC b){return CC((x+b.x)%MOD);}
CC operator-(CC b){return CC((x+MOD-b.x)%MOD);}
CC operator*(CC b){return CC((ll)x*b.x%MOD);}
CC& operator*=(CC b){x=(ll)x*b.x%MOD; return *this;}
};
template<typename T>
T qpow(T a, int t){
T ans = T(1);
while(t){
if(t&1) ans *= a;
a *= a;
t >>= 1;
}
return ans;
}
CC inverse(int x){
return qpow(CC(x), MOD-2);
}
void change(CC *y, int len){
std::vector<int> rev;
rev.reserve(len);
rev[0] = 0;
UP(i, 1, len){
rev[i] = rev[i>>1] >> 1;
if(i&1) rev[i] |= len>>1;
}
UP(i, 0, len) if(i<rev[i]) std::swap(y[i], y[rev[i]]);
}
void ntt(CC *y, int len, int on){
change(y, len);
for(int h=2; h<=len; h<<=1){
CC wn = qpow(CC(3), (MOD-1)/h);
for(int j=0; j<len; j+=h){
CC w = 1;
UP(k, j, j+h/2){
CC u = y[k], v = w * y[k+h/2];
y[k] = u+v, y[k+h/2] = u-v;
w = w * wn;
}
}
}
if(on == -1){
std::reverse(y+1, y+len);
CC inv = inverse(len);
UP(i, 0, len){
y[i] *= inv;
}
}
}
CC ia[1<<21], ib[1<<21], ic[1<<21];
int in, im;
void work(){
scanf("%d%d", &in, &im);
UP(i, 0, in+1) scanf("%d", &ia[i].x);
UP(i, 0, im+1) scanf("%d", &ib[i].x);
int len = 1;
while(len < in+im+1) len<<=1;
ntt(ia, len, 1);
ntt(ib, len, 1);
UP(i, 0, len){
ic[i] = ia[i] * ib[i];
}
ntt(ic, len, -1);
UP(i, 0, in+im+1){
printf("%d ", ic[i].x);
}
}
}
int main(){m::work(); return 0;}
Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
Subtask #1 Testcase #1 | 3.44 ms | 24 MB + 24 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #2 | 78.439 ms | 26 MB + 452 KB | Accepted | Score: 100 | 显示更多 |
Subtask #1 Testcase #3 | 37.898 ms | 24 MB + 816 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #4 | 37.959 ms | 24 MB + 804 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #5 | 3.442 ms | 24 MB + 24 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #6 | 3.441 ms | 24 MB + 24 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #7 | 3.44 ms | 24 MB + 24 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #8 | 72.574 ms | 26 MB + 184 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #9 | 72.611 ms | 26 MB + 184 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #10 | 66.818 ms | 25 MB + 940 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #11 | 78.723 ms | 26 MB + 532 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #12 | 78.628 ms | 25 MB + 412 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #13 | 3.44 ms | 24 MB + 24 KB | Accepted | Score: 0 | 显示更多 |