#include<bits/stdc++.h>
#define Dec(x,y) ((x-=y)<0&&(x+=mod))
#define Inc(x,y) ((x+=y)<mod||(x-=mod))
#define ll long long
using namespace std;
const int mod=998244353;
const int gen=3;
const int N=1<<21|5;
inline int fsp(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 Math{
int initdw=2,initdinv=2,w[N],iv[N];
inline void initw(int x){
(!w[1])&&(w[1]=1);
for(int k=initdw;k<x;k<<=1){
w[k]=1;w[k+1]=fsp(3,(mod-1)/(k<<1));
for(int i=2;i<k;i++)w[i+k]=1ll*w[i+k-1]*w[k+1]%mod;
}initdw=max(initdw,x);
}inline void initinv(int x){
(!iv[1])&&(iv[1]=1);
for(int i=initdinv;i<=x;i++)iv[i]=1ll*(mod-mod/i)*iv[mod%i]%mod;
initdinv=max(x+1,initdinv);
}inline int ginv(int x){
(x<(1<<21))&&(initinv(x),0);
return x<initdinv?iv[x]:fsp(x,mod-2);
}inline void ntt(int *a,int lim,bool fl=1){
static int rev[N];static unsigned ll A[N];initw(lim);
for(int i=0;i<lim;i++)A[i]=a[rev[i]=rev[i>>1]>>1|((i&1)?lim>>1:0)];
for(int k=1;k<lim;k<<=1)for(int j=0;j<lim;j+=k<<1)
for(int i=j,t;i<j+k;i++){t=A[i+k]*w[i-j+k]%mod;A[i+k]=A[i]+mod-t,A[i]=A[i]+t;}
if(!fl){reverse(A+1,A+lim);for(int i=0,iv=ginv(lim);i<lim;i++)a[i]=A[i]%mod*iv%mod;}
else for(int i=0;i<lim;i++)a[i]=A[i]%mod;
}
}namespace Poly{
using Math::ntt;
#define vc vector<int>
int A[N];
struct poly{
vc f;poly(int x=0){f.clear();(x)&&(f.push_back(x),0);}
poly(int *a,int n){f.resize(n);memcpy(f.data(),a,n<<2);}
inline int operator[](int x)const{return x<f.size()?f.at(x):0;}inline int& operator[](int x){return f.at(x);}
inline int size()const{return f.size();}inline void resize(int x){return f.resize(x);}
inline int* data(){return f.data();}inline const int* data()const{return f.data();}
inline void copy(int *a,int len){
memcpy(a,f.data(),min(len,size())<<2);
(f.size()<len)&&(memset(a+f.size(),0,len-f.size()<<2),0);
}inline poly& operator *=(const poly& a){
int lim=1;while(lim<a.size()+f.size()-1)lim<<=1;
f.resize(lim);memcpy(A,a.data(),a.size()<<2);
ntt(f.data(),lim);ntt(A,lim);for(int i=0;i<lim;i++)f[i]=1ll*f[i]*A[i]%mod;
ntt(f.data(),lim,0);memset(A,0,lim<<2);return *this;
}inline poly operator *(const poly& a)const{poly b(*this);(b*=a).resize(f.size()+a.size()-1);return b;}
inline void print(char ch=' ')const{
for(int i=0;i<f.size();i++,putchar(ch))printf("%d",f[i]);
putchar('\n');
}
};
}
using Poly::poly;
int n,m,a[N],b[N];
poly f;
int main(){
scanf("%d%d",&n,&m);++n;++m;
for(int i=0;i<n;i++)scanf("%d",a+i);
for(int i=0;i<m;i++)scanf("%d",b+i);
(poly(a,n)*poly(b,m)).print();
return 0;
}
| Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
| Subtask #1 Testcase #1 | 39.37 us | 64 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #2 | 47.341 ms | 10 MB + 392 KB | Accepted | Score: 100 | 显示更多 |
| Subtask #1 Testcase #3 | 20.729 ms | 4 MB + 612 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #4 | 20.741 ms | 4 MB + 996 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #5 | 42.34 us | 64 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #6 | 40.06 us | 64 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #7 | 39.83 us | 64 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #8 | 42.086 ms | 9 MB + 748 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #9 | 42.31 ms | 9 MB + 884 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #10 | 37.083 ms | 9 MB + 212 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #11 | 47.685 ms | 10 MB + 472 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #12 | 47.156 ms | 9 MB + 352 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #13 | 38.96 us | 64 KB | Accepted | Score: 0 | 显示更多 |