1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
|
#include<bits/stdc++.h> #define re register typedef long long ll; template<class T> inline void read(T &x) { x=0; char ch=getchar(),t=0; while(ch<'0'||ch>'9') t|=ch=='-',ch=getchar(); while(ch>='0'&&ch<='9') x=(x<<3)+(x<<1)+(ch^48),ch=getchar(); if(t) x=-x; } template<class T,class ...T1> inline void read(T &x,T1 &...x1){ read(x),read(x1...); } template<class T> inline void write(T x) { if(x<0) putchar('-'),x=-x; if(x>9) write(x/10); putchar(x%10+'0'); } template<> inline void write(bool x){ putchar(x?'1':'0'); } template<> inline void write(char c){ putchar(c); } template<> inline void write(char *s){ while(*s!='\0') putchar(*s++); } template<> inline void write(const char *s){ while(*s!='\0') putchar(*s++); } template<class T,class ...T1> inline void write(T x,T1 ...x1){ write(x),write(x1...); } template<class T> inline bool checkMax(T &x,T y){ return x<y?x=y,1:0; } template<class T> inline bool checkMin(T &x,T y){ return x>y?x=y,1:0; } const int MAXN=2e5+10; const int P=998244353,G=3,invG=332748118; int N; ll f[MAXN],g[MAXN]; inline ll qPow(ll a,ll b) { ll res=1; while(b) { if(b&1) res=res*a%P; a=a*a%P;b>>=1; } return res; } int Tot,Bit,Rev[MAXN]; inline void NTT(ll a[],int n,int inv) { for(int i=0;i<n;++i) if(i<Rev[i]) std::swap(a[i],a[Rev[i]]); for(int mid=1;mid<n;mid<<=1) { ll w1=qPow(inv==1?G:invG,(P-1)/(mid<<1)); for(int i=0;i<n;i+=mid*2) { ll wk=1; for(int j=0;j<mid;++j,wk=wk*w1%P) { ll x=a[i+j],y=a[i+j+mid]*wk%P; a[i+j]=(x+y)%P,a[i+j+mid]=(x-y+P)%P; } } } if(inv==-1) { ll iv=qPow(n,P-2); for(int i=0;i<n;++i) a[i]=a[i]*iv%P; } } inline void Mul(ll a[],ll b[],int n,int bit) { for(int i=0;i<n;++i) Rev[i]=(Rev[i>>1]>>1)|((i&1)<<(bit-1)); NTT(a,n,1),NTT(b,n,1); for(int i=0;i<n;++i) a[i]=a[i]*b[i]%P; NTT(a,n,-1); } ll a[MAXN],b[MAXN]; void Divide(ll f[],ll g[],int l,int r) { if(l==r) return ; int mid=(l+r)>>1,len=r-l+1,bit=0,tot; Divide(f,g,l,mid); while((1<<bit)<=len) ++bit; tot=1<<bit; std::memset(a,0,tot*sizeof(ll)); std::memset(b,0,tot*sizeof(ll)); for(int i=l;i<=mid;++i) a[i-l]=f[i]; for(int i=1;i<=r-l;++i) b[i-1]=g[i]; Mul(a,b,tot,bit); for(int i=mid+1;i<=r;++i) f[i]=(f[i]+a[i-l-1])%P; Divide(f,g,mid+1,r); } signed main() { read(N),f[0]=1; for(int i=1;i<N;++i) read(g[i]); Divide(f,g,0,N-1); for(int i=0;i<N;++i) write(f[i],' '); return 0; }
|