#include <bits/stdc++.h>
#define maxn 500005
#define mod 998244353
#define LL long long
using namespace std;
int Wl,Wl2,w[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 int r[maxn]={}; static unsigned LL ar[maxn]={};
int n=1<<bit; if(tp^1) reverse(A+1,A+n);
for(int i=0;i<n;i++) r[i]=(r[i>>1]>>1|(i&1)<<bit-1),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 {
inline char nc(){
static char buf[500005],*p1=buf,*p2=buf;
return p1==p2&&(p2=(p1=buf)+fread(buf,1,500000,stdin),p1==p2)?EOF:*p1++;
}
char out[500005],*pout=out,*eout=out+500000;
inline void flush() { fwrite(out,1,pout-out,stdout),pout=out; }
inline void pc(char c) { pout==eout&&(fwrite(out,1,500000,stdout),pout=out); (*pout++)=c; }
template<typename T> inline void put(T 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 sum=0; for(;ch<'0'||ch>'9';ch=nc());
while(ch>='0'&&ch<='9')sum=(sum<<1)+(sum<<3)+ch-48,ch=nc();
return sum;
}
}
#define Rint IO::read()
using IO::put;
int n,m,A[maxn],B[maxn];
int main() { // freopen("input","r",stdin);
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++; 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 | 35.47 us | 68 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #2 | 1 s | 2 MB + 964 KB | Time Limit Exceeded | Score: -100 | 显示更多 |
| Subtask #1 Testcase #3 | 8.241 ms | 4 MB + 312 KB | Accepted | Score: 100 | 显示更多 |
| Subtask #1 Testcase #4 | 8.272 ms | 4 MB + 288 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #5 | 36.45 us | 68 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #6 | 34.6 us | 68 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #7 | 34.83 us | 68 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #8 | 1 s | 2 MB + 764 KB | Time Limit Exceeded | Score: 0 | 显示更多 |
| Subtask #1 Testcase #9 | 1 s | 2 MB + 764 KB | Time Limit Exceeded | Score: 0 | 显示更多 |
| Subtask #1 Testcase #10 | 1 s | 2 MB + 560 KB | Time Limit Exceeded | Score: 0 | 显示更多 |
| Subtask #1 Testcase #11 | 1 s | 2 MB + 964 KB | Time Limit Exceeded | Score: 0 | 显示更多 |
| Subtask #1 Testcase #12 | 1 s | 2 MB + 964 KB | Time Limit Exceeded | Score: 0 | 显示更多 |
| Subtask #1 Testcase #13 | 36.01 us | 64 KB | Accepted | Score: 0 | 显示更多 |