// SPDX-License-Identifier: CC0-1.0 // // [English] // To the extent possible under law, the author(s) have dedicated all copyright // and related and neighboring rights to this software to the public domain // worldwide. This software is distributed without any warranty. // See for details. // // [日本語] // 法律上可能な範囲で、著作者はこのソフトウェアに関する著作権および // 著作隣接権を含むすべての関連する権利を、全世界でパブリックドメインに // 提供しています。本ソフトウェアは一切の保証なく配布されます。 // 自由にコピー・改変・再配布・商用利用できます(クレジット表記は不要です)。 // 詳細は を参照してください。 // ※ 英語の文面および CC0 1.0 の正式な条文(英語)が優先されます。 #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using ll=long long; #include using mint=atcoder::modint998244353; ostream& operator<<(ostream& os,const mint& x){ os<>(istream& is,mint& x){ int t; is>>t; x=t; return is; } template ostream& operator<<(ostream& os,const pair& p); template istream& operator>>(istream& is,pair& p); template ostream& operator<<(ostream& os,const array& arr); template istream& operator>>(istream& is,array& arr); template ostream& operator<<(ostream& os,const vector& vec); template istream& operator>>(istream& is,vector& vec); template ostream& operator<<(ostream& os,const pair& p){ os< istream& operator>>(istream& is,pair& p){ is>>p.first>>p.second; return is; } template ostream& operator<<(ostream& os,const array& arr){ for(int i=0;i istream& operator>>(istream& is,array& arr){ for(int i=0;i>arr[i]; return is; } template ostream& operator<<(ostream& os,const vector& vec){ for(int i=0;i<(int)vec.size();i++)os< istream& operator>>(istream& is,vector& vec){ for(int i=0;i<(int)vec.size();i++)is>>vec[i]; return is; } template void input_vec(Vecs&... vs) { const auto n = get<0>(tie(vs...)).size(); for (size_t i = 0; i < n; ++i) ((cin >> vs[i]), ...); } template void output_vec(const Vecs&... vs) { const auto n = get<0>(tie(vs...)).size(); for (size_t i = 0; i < n; ++i) { bool first = true; (((cout << (exchange(first, false) ? "" : " ") << vs[i])), ...); cout << endl; } } template vector make_unique(vector vec){ ranges::sort(vec); vec.erase(unique(vec.begin(),vec.end()),vec.end()); return vec; } vector Iota(int n,int s=0){ vector res(n); iota(res.begin(),res.end(),s); return res; } vector Iotall(int n,ll s=0){ vector res(n); iota(res.begin(),res.end(),s); return res; } void YESNO(bool f){ if(f)cout<<"Yes"<; using vvl=vector>; using vvvl=vector>>; using vi=vector; using vvi=vector>; using vvvi=vector>>; struct Combination{ Combination(int n){ init(n); } Combination(){}; private: int n; vector _fact,_factinv; void init(int n){ this->n=n; _fact.resize(n+1,1);_factinv.resize(n+1,1); for(int i=0;i=0;i--)_factinv[i]=_factinv[i+1]*(i+1); } public: mint fact(int x){ return _fact[x]; } mint factinv(int x){ return _factinv[x]; } mint C(int x,int y){ assert(0<=x&&x<=n&&0<=y); if(x(a-1,b) void down_binomsum_a(int& a,int& b,mint& c){ c-=comb.C(b,a-1); } //(a,b)->(a+1,b) void up_binomsum_a(int& a,int& b,mint& c){ c+=comb.C(b,a); } //(a,b)->(a,b-1) void down_binomsum_b(int& a,int& b,mint& c){ if(a!=0) c=(c+comb.C(b-1,a-1))*comb.frac(1,2); } //(a,b)->(a,b+1) void up_binomsum_b(int& a,int& b,mint& c){ if(a!=0) c=2*c-comb.C(b,a-1); } int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout<>n; vector> dp(n+1,vector(3)); dp[0][1]=1; for(int i=0;i> ndp(n+1,vector(3)); for(int j=0;j<=n;j++){ if(j>0){ ndp[j][0]+=dp[j-1][1]+dp[j-1][2]; } ndp[j][1]=dp[j][0]; ndp[j][2]=dp[j][1]; } dp=ndp; } comb=Combination(n+3); mint ans=0; for(int i=0;i<=n;i++){ for(int j=0;j<2;j++)ans+=comb.fact(i)*comb.fact(n-i)*dp[i][j]; } cout<