#include<bits/stdc++.h>
using namespace std;
const int mod=998244353;
const int gen=3,ivg=332748118;
const int N=1<<21|5;
inline int fp(int x,int y){int ans=1;for(;y;y>>=1,x=1ll*x*x%mod)(y&1)&&(ans=1ll*ans*x%mod);return ans;}
namespace Poly{
struct lsp{
int A[1<<5|5];
lsp(int x=0){
A[22]=fp(x,mod>>22);
for(int i=22;i;i--)A[i-1]=1ll*A[i]*A[i]%mod;
}inline int operator ()(const int x)const{return A[x];}
}pw[2]={ivg,gen};
int rev[N];
inline void ntt(int *a,int lim,int fl=1){
for(int i=0;i<lim;i++){
rev[i]=(rev[i>>1]>>1)|((i&1)?(lim>>1):0);
(i<rev[i])&&(swap(a[i],a[rev[i]]),0);
}for(int k=1,o=1;k<lim;k<<=1,++o){long long w=1;
for(int i=0;i<k;i++,w=w*pw[fl](o)%mod){long long t=w*a[i+k];
for(int j=0;j<lim;t=w*a[i+k+(j+=k<<1)])
a[i+j+k]=(a[i+j]-t)%mod,a[i+j]=(a[i+j]+t)%mod;
}
}if(!fl)for(int i=0,iv=fp(lim,mod-2);i<lim;i++)a[i]=1ll*a[i]*iv%mod;
}
int A[N],B[N];
#define bs basic_string<int>
struct poly{
bs f;
int n;
poly(const int x=0){
f.clear();n=0;
(x)&&(f.push_back(x),++n);
}poly(const int *a,const int x){
n=x;f.resize(n);
for(int i=0;i<n;i++)f[i]=a[i];
}inline int& operator [](const int x){return f[x];}
inline int operator [](const int x)const{return f[x];}
inline poly operator +(const poly& a)const{
for(int i=0;i<n;i++)A[i]=f[i];for(int i=0;i<a.n;i++)B[i]=a[i];
int m=max(n,a.n);for(int i=0;i<m;i++)A[i]=(A[i]+B[i])%mod;
poly b=poly(A,m);for(int i=0;i<m;i++)A[i]=B[i]=0;
return b;
}inline poly operator -(const poly& a)const{
for(int i=0;i<n;i++)A[i]=f[i];for(int i=0;i<a.n;i++)B[i]=a[i];
int m=max(n,a.n);for(int i=0;i<m;i++)A[i]=(A[i]-B[i])%mod;
poly b=poly(A,m);for(int i=0;i<m;i++)A[i]=B[i]=0;
return b;
}inline poly operator *(const poly& a)const{
for(int i=0;i<n;i++)A[i]=f[i];for(int i=0;i<a.n;i++)B[i]=a[i];
int lim=1;while(lim<n+a.n)lim<<=1;ntt(A,lim);ntt(B,lim);
for(int i=0;i<lim;i++)A[i]=1ll*A[i]*B[i]%mod;ntt(A,lim,0);
poly b=poly(A,n+a.n-1);for(int i=0;i<lim;i++)A[i]=B[i]=0;
return b;
}
};
#undef bs
}
using Poly::poly;
int f[N],g[N],n,m;
poly h;
int main(){
scanf("%d%d",&n,&m);++n;++m;
for(int i=0;i<n;i++)scanf("%d",f+i);
for(int i=0;i<m;i++)scanf("%d",g+i);
h=poly(f,n)*poly(g,m);
for(int i=0;i<h.n;i++)printf("%d ",(h[i]+mod)%mod);
return 0;
}
| Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
| Subtask #1 Testcase #1 | 37.57 us | 56 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #2 | 83.146 ms | 6 MB + 780 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #3 | 36.698 ms | 2 MB + 996 KB | Accepted | Score: 100 | 显示更多 |
| Subtask #1 Testcase #4 | 36.616 ms | 2 MB + 988 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #5 | 40.22 us | 56 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #6 | 40.13 us | 56 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #7 | 38.21 us | 56 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #8 | 77.258 ms | 6 MB + 108 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #9 | 77.345 ms | 6 MB + 112 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #10 | 71.411 ms | 5 MB + 460 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #11 | 83.407 ms | 6 MB + 860 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #12 | 81.882 ms | 5 MB + 740 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #13 | 37.26 us | 56 KB | Accepted | Score: 0 | 显示更多 |