#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){int w=1,nw=pw[fl](0);
for(int i=0;i<k;i++,w=1ll*w*nw%mod){int t=1ll*w*a[i+k]%mod;
for(int j=0;j<lim;t=1ll*w*a[i+k+(j+=k<<1)]%mod)
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.resize(n=1);f[0]=x;
}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.66 us | 56 KB | Wrong Answer | Score: 0 | 显示更多 |
| Subtask #1 Testcase #2 | 89.415 ms | 6 MB + 484 KB | Wrong Answer | Score: 0 | 显示更多 |
| Subtask #1 Testcase #3 | 39.6 ms | 2 MB + 996 KB | Wrong Answer | Score: 0 | 显示更多 |
| Subtask #1 Testcase #4 | 39.494 ms | 2 MB + 988 KB | Wrong Answer | Score: 0 | 显示更多 |
| Subtask #1 Testcase #5 | 42.47 us | 56 KB | Wrong Answer | Score: 0 | 显示更多 |
| Subtask #1 Testcase #6 | 38.9 us | 56 KB | Wrong Answer | Score: 0 | 显示更多 |
| Subtask #1 Testcase #7 | 39.11 us | 56 KB | Wrong Answer | Score: 0 | 显示更多 |
| Subtask #1 Testcase #8 | 83.284 ms | 5 MB + 972 KB | Wrong Answer | Score: 0 | 显示更多 |
| Subtask #1 Testcase #9 | 83.109 ms | 5 MB + 976 KB | Wrong Answer | Score: 0 | 显示更多 |
| Subtask #1 Testcase #10 | 76.123 ms | 5 MB + 244 KB | Wrong Answer | Score: 0 | 显示更多 |
| Subtask #1 Testcase #11 | 89.295 ms | 6 MB + 484 KB | Wrong Answer | Score: 0 | 显示更多 |
| Subtask #1 Testcase #12 | 88.653 ms | 5 MB + 740 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #13 | 38.02 us | 56 KB | Accepted | Score: 0 | 显示更多 |