#include<bits/stdc++.h>
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fstrict-overflow")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-skip-blocks")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-fhoist-adjacent-loads")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-funsafe-loop-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")
#define P 998244353
#define N 262144
using namespace std;
namespace IO
{
char ibuf[(1<<21)+1],obuf[(1<<21)+1],st[15],*iS,*iT,*oS=obuf,*oT=obuf+(1<<21);
char Get(){return (iS==iT? (iT=(iS=ibuf)+fread(ibuf,1,(1<<21)+1,stdin),(iS==iT? EOF:*iS++)):*iS++);}
void Flush(){fwrite(obuf,1,oS-obuf,stdout),oS=obuf;}
void Put(char x){*oS++=x;if(oS==oT)Flush();}
int read(){int x=0,c=Get();while(!isdigit(c))c=Get();while(isdigit(c))x=x*10+c-48,c=Get();return x;}
void write(int x){int top=0;if(!x)Put('0');while(x)st[++top]=(x%10)+48,x/=10;while(top)Put(st[top--]);Put(' ');}
}using namespace IO;
using u64=unsigned long long;
int mod(int x){return x+=x>>31&P;}
int power(u64 a,int k){u64 r(1);for(;k;k>>=1,a=a*a%P)if(k&1)r=r*a%P;return r;}
int lim(1),rev[N],w[N];
int getlen(int n){return 1<<(32-__builtin_clz(n));}
void init(int n)
{
int l(-1);
while(lim<=n) lim<<=1,++l;
for(int i=1;i<lim;++i) rev[i]=(rev[i>>1]>>1)|((i&1)<<l);
int g(power(3,(P-1)>>(++l)));
w[lim>>1]=1;
for(int i=(lim>>1)+1;i<lim;++i) w[i]=(u64)w[i-1]*g%P;
for(int i=(lim>>1)-1;i;--i) w[i]=w[i<<1];
lim=l;
}
void NTT(int*a,int l,int f)
{
if(!f) reverse(a+1,a+l);
static u64 t[N];
int x,p(P-(P-1)/l);
for(int i=0;i<l;++i) t[rev[i]]=a[i];
for(int i=1;i<l;i<<=1) for(int j=0,d=i<<1;j<l;j+=d) for(int k=0;k<i;++k) x=t[i+j+k]*w[i+k]%P,t[i+j+k]=t[j+k]+P-x,t[j+k]+=x;
for(int i=0;i<l;++i) a[i]=t[i]%P;
if(!f) for(int i=0;i<l;++i) a[i]=(u64)a[i]*p%P;
}
int f[N],g[N];
int main()
{
int n=read(),m=read(),l=getlen(n+m+1);
init(n+m+1);
for(int i=0;i<=n;++i) f[i]=read();
for(int i=0;i<=m;++i) g[i]=read();
NTT(f,l,1),NTT(g,l,1);
for(int i=0;i<l;++i) f[i]=(u64)f[i]*g[i]%P;
NTT(f,l,0);
for(int i=0;i<=n+m;++i) write(f[i]);
return Flush(),0;
}
| Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
| Subtask #1 Testcase #1 | 38.47 us | 64 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #2 | 21.547 ms | 9 MB + 268 KB | Accepted | Score: 100 | 显示更多 |
| Subtask #1 Testcase #3 | 8.518 ms | 3 MB + 820 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #4 | 8.556 ms | 3 MB + 800 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #5 | 37.85 us | 64 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #6 | 36.71 us | 64 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #7 | 36.05 us | 64 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #8 | 20.787 ms | 8 MB + 688 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #9 | 20.747 ms | 8 MB + 688 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #10 | 19.966 ms | 8 MB + 84 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #11 | 21.824 ms | 9 MB + 428 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #12 | 18.814 ms | 7 MB + 184 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #13 | 35.92 us | 64 KB | Accepted | Score: 0 | 显示更多 |