#include <bits/stdc++.h>
#define maxn 600005
#define mod 998244353
#define LL long long
using namespace std;
int Wl,Wl2,w[maxn],r[maxn];
inline int Pow(int b, int k) { int r=1; for(;k;k>>=1,b=1ll*b*b%mod) if(k&1) r=1ll*r*b%mod; return r; }
inline void init(int n) {
for(Wl=1;n>=Wl<<1;Wl<<=1); int pw=Pow(3,(mod-1)/(Wl2=Wl<<1)); w[Wl]=1;
for(int i=Wl+1;i<=Wl2;i++) w[i]=w[i-1]*1ll*pw%mod; for(int i=Wl-1;i>=1;i--) w[i]=w[i<<1];
}
inline int upd(int x) { return x+=x>>31&mod; }
inline void NTT(int *A, int bit, int tp) {
static unsigned LL ar[maxn]={};
int n=1<<bit; if(tp^1) reverse(A+1,A+n);
for(int i=0;i<n;i++) ar[i]=upd(A[r[i]]);
for(int L=1;L<n;L<<=1) for(int s=0,L2=L<<1;s<n;s+=L2)
for(int k=s,x=L,t;x<L2;x++,k++) t=ar[k+L]*w[x]%mod,ar[k+L]=ar[k]-t+mod,ar[k]+=t;
for(int i=0;i<n;i++) A[i]=ar[i]%mod;
if(tp^1) for(int i=0,iv=Pow(n,mod-2);i<n;i++) A[i]=1ll*A[i]*iv%mod;
}
inline int Init(int n) { int m; for(m=1;m<n;m<<=1); init(m); return m; }
namespace IO {
const int len=1<<18;
char buf[len],*p1=buf,*p2=buf;
#define nc (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<18,stdin),p1==p2)?EOF:*p1++)
char out[len],*pout=out,*eout=out+len;
inline void flush() { fwrite(out,1,pout-out,stdout),pout=out; }
inline void pc(char c) { pout==eout&&(fwrite(out,1,len,stdout),pout=out); (*pout++)=c; }
inline void put(int x,char suf=' ') {
static char stk[40];int top=0;
while(x) stk[top++]=x%10,x/=10;
!top?pc('0'),0:0; while(top--) pc(stk[top]+'0');
pc(suf);
}
inline int read(){
char ch=nc; int x=0; for(;ch<'0'||ch>'9';ch=nc);
for(x=ch-48,ch=nc;ch>='0'&&ch<='9';ch=nc)x=x*10+ch-48;
return x;
}
}
#define Rint IO::read()
using IO::put;
int n,m,A[maxn],B[maxn];
int main() {
n=Rint+1;m=Rint+1; Init(n+m);
for(int i=0;i<n;i++) A[i]=Rint; for(int i=0;i<m;i++) B[i]=Rint;
int N=n+m-1,M=1; while((1<<M)<=N) M++;
for(int i=0;i<(1<<M);i++) r[i]=(r[i>>1]>>1|(i&1)<<M-1);
NTT(A,M,1); NTT(B,M,1);
for(int i=0;i<(1<<M);i++) A[i]=1ll*A[i]*B[i]%mod; NTT(A,M,-1);
for(int i=0;i<N;i++) put(A[i],' '); IO::flush();
}
Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
Subtask #1 Testcase #1 | 34.71 us | 64 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #2 | 20.082 ms | 8 MB + 996 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #3 | 7.902 ms | 4 MB + 280 KB | Accepted | Score: 100 | 显示更多 |
Subtask #1 Testcase #4 | 7.909 ms | 4 MB + 268 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #5 | 38.16 us | 64 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #6 | 35.86 us | 64 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #7 | 36.32 us | 64 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #8 | 19.373 ms | 8 MB + 728 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #9 | 19.408 ms | 8 MB + 728 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #10 | 18.735 ms | 8 MB + 460 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #11 | 20.271 ms | 9 MB + 52 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #12 | 17.437 ms | 7 MB + 956 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #13 | 35.74 us | 64 KB | Accepted | Score: 0 | 显示更多 |