// Problem: No.2605 Pickup Parentheses // Contest: yukicoder // URL: https://yukicoder.me/problems/no/2605 // Memory Limit: 512 MB // Time Limit: 2000 ms #include #define debug(x) cerr<<(#x)<<" "<<(x)< #define rep(i,a,b) for(ll i=(a);i<=(b);++i) #define per(i,a,b) for(ll i=(a);i>=(b);--i) using namespace std; bool Mbe; ll read(){ ll x=0,f=1;char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();} while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();} return x*f; } void write(ll x){ if(x<0)putchar('-'),x=-x; if(x>9)write(x/10); putchar(x%10+'0'); } const ll N=2e6+9,Mod=998244353,G=3,IG=332748118; ll n,m,a[N],fac[N],ifac[N],r[N],cat[N]; ll pw(ll x,ll p){ ll res=1; while(p){ if(p&1)res=res*x%Mod; x=x*x%Mod; p>>=1; } return res; } void NTT(vector&a,ll n,ll sgn){ rep(i,0,n-1){ if(i&f,vectorg,ll n,ll m){ ll mxlen=n+m; ll p=1,c=0; while(p<=mxlen)p<<=1,c++; f.resize(p),g.resize(p); r[0]=0; rep(i,1,p-1)r[i]=(r[i>>1]>>1)|((i&1)<<(c-1)); NTT(f,p,1),NTT(g,p,1); rep(i,0,p-1)f[i]=f[i]*g[i]%Mod; NTT(f,p,-1); f.resize(n+m-1); } vector work(ll l,ll r){ if(l==r){ vectorvec(a[l]+1,0); vec[0]=1,vec[a[l]]=Mod-cat[a[l]/2]; return vec; } ll mid=(l+r)>>1; vectorlf=work(l,mid); vectorrg=work(mid+1,r); MUL(lf,rg,(ll)lf.size(),(ll)rg.size()); return lf; } bool Med; int main(){ cerr<f=work(1,m); ll ans=0; rep(i,0,min((ll)f.size()-1,n))ans=(ans+cat[n/2-i/2]*f[i])%Mod; write(ans); return 0; }