#include<cmath>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define M 10
#define N1 2100010
#define P 998244353
#define g 3
using namespace std;
typedef long long ll;
int n,m,N,rev[N1],lg;
char s[1000010],stk[10];
ll ans[N1],a[N1],b[N1];
ll ksm(ll x,ll y,ll p)
{
ll res = 1;
while(y > 0)
{
if(y & 1) res = res * x % p;
x = x * x % p;
y = y >> 1;
}
return res;
}
void NTT(ll a[],int xs)
{
int l = 1;
for(int i = 0;i < N;i++)
{
rev[i] = (rev[i >> 1] >> 1) | ((i & 1) << lg - 1);
if(i < rev[i])
{
ll t = a[i];
a[i] = a[rev[i]];
a[rev[i]] = t;
}
}
int mi = 1;
for(int i = 1;i <= lg;i++)
{
ll w = ksm(g,(P - 1) >> i,P);
if(xs == -1) w = ksm(w,P - 2,P);
for(int j = 0;j < N;j += (1 << i))
{
ll w1 = 1;
for(int k = 0;k < mi;k++)
{
ll t = w1 * a[j + k + mi] % P,u = a[j + k];
a[j + k] = (u + t) % P;
a[j + k + mi] = (u - t + P) % P;
w1 = w1 * w % P;
}
}
mi = (mi << 1) % P;
}
if(xs == -1)
{
ll ny = ksm(N,P - 2,P);
for(int i = 0;i < N;i++) a[i] = a[i] * ny % P;
}
}
int main()
{
scanf("%d%d",&n,&m);
for(int i = 0;i <= n;i++) scanf("%lld",&a[i]);
for(int i = 0;i <= m;i++) scanf("%lld",&b[i]);
N = 1;
while(N <= m + n)
{
N = N << 1;
lg++;
}
NTT(a,1);
NTT(b,1);
for(int i = 0;i < N;i++) a[i] = a[i] * b[i] % P;
NTT(a,-1);
for(int i = 0;i <= n + m;i++) printf("%lld ",a[i]);
return 0;
}
| Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
| Subtask #1 Testcase #1 | 11.16 us | 28 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #2 | 73.096 ms | 6 MB + 456 KB | Accepted | Score: 100 | 显示更多 |
| Subtask #1 Testcase #3 | 34.285 ms | 2 MB + 820 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #4 | 34.431 ms | 2 MB + 808 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #5 | 12.17 us | 28 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #6 | 11.51 us | 28 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #7 | 11.39 us | 28 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #8 | 67.298 ms | 6 MB + 188 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #9 | 67.263 ms | 6 MB + 188 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #10 | 61.327 ms | 5 MB + 944 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #11 | 73.56 ms | 6 MB + 536 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #12 | 73.295 ms | 5 MB + 416 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #13 | 9.99 us | 28 KB | Accepted | Score: 0 | 显示更多 |