#include<set>
#include<map>
#include<cmath>
#include<cstdio>
#include<bitset>
#include<vector>
#include<cstring>
#include<algorithm>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
const int N=4194310,P=998244353;
struct IO_tp
{
static const int Sbuf=1<<21;
char buf[Sbuf], *S, *T, c; int f;
#define gc() (S==T?(T=(S=buf)+fread(buf,1,sizeof(buf),stdin),(S==T?EOF:*S++)):*S++)
template<class I>
inline IO_tp& operator >> (I &x)
{
for(f=1, c=gc(); c<'0'||c>'9'; c=gc()) if(c=='-') f=-1;
for(x=0; c>='0'&&c<='9'; c=gc()) x=x*10+(c^48); x*=f;
return *this;
}
}io;
char out[N],*O=out,qu[50];
inline void print(int x)
{
int s=0;
if(!x) *O++='0';
while(x) qu[++s]=x%10+'0',x/=10;
while(s) *O++=qu[s--];
}
int fpow(int a,int b)
{
ll w(1),o(a);
while(b)
{
if(b&1)w=w*o%P;
o=o*o%P;
b>>=1;
}
return w;
}
const int G=2333333,iG=fpow(G,P-2);
int n,m,A[N],B[N],L,U,h[N];
void NTT(int*f,int T)
{
int w,wn,x,y;
for(int i=0; i<U; i++)
if(i<h[i])
swap(f[i],f[h[i]]);
for(int l=1; l<U; l<<=1)
{
wn=fpow(T>0?G:iG,(P-1)/(l<<1));
for(int i=0; i<U; i+=l<<1)
{
w=1;
for(int j=i; j<i+l; j++)
{
x=f[j];
y=(ll)f[j+l]*w%P;
f[j]=(x+y)%P;
f[j+l]=(x+P-y)%P;
w=(ll)w*wn%P;
}
}
}
if(T<0)
{
w=fpow(U,P-2);
for(int i=0; i<U; i++)
f[i]=(ll)f[i]*w%P;
}
}
int main()
{
io>>n>>m;
for(int i=0; i<=n; i++)io>>A[i];
for(int i=0; i<=m; i++)io>>B[i];
for(U=1; U<=n+m; U<<=1)L++;
for(int i=0; i<U; i++)
h[i]=(h[i>>1]>>1)|((i&1)<<(L-1));
NTT(A, 1);
NTT(B, 1);
for(int i=0; i<U; i++)
A[i]=(ll)A[i]*B[i]%P;
NTT(A,-1);
for(int i=0; i<=n+m; i++)
{
print(A[i]);
*O++=' ';
}
fwrite(out,1,O-out,stdout);
return 0;
}
Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
Subtask #1 Testcase #1 | 8.08 us | 32 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #2 | 44.521 ms | 6 MB + 256 KB | Accepted | Score: 100 | 显示更多 |
Subtask #1 Testcase #3 | 20.102 ms | 2 MB + 276 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #4 | 20.128 ms | 2 MB + 256 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #5 | 9.6 us | 32 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #6 | 9 us | 32 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #7 | 8.26 us | 32 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #8 | 43.779 ms | 5 MB + 676 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #9 | 43.794 ms | 5 MB + 676 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #10 | 43.122 ms | 5 MB + 72 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #11 | 44.789 ms | 6 MB + 416 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #12 | 41.864 ms | 4 MB + 172 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #13 | 7.26 us | 32 KB | Accepted | Score: 0 | 显示更多 |