#include #include #include namespace nachia{ template struct MatrixModulo{ private: int h; int w; std::vector elems; public: MatrixModulo(int new_h, int new_w){ h = new_h; w = new_w; elems.assign(h * w, 0); } MatrixModulo(const MatrixModulo&) = default; int height() const { return h; } int width() const { return w; } typename std::vector::iterator operator[](int y){ return elems.begin() + (y * w); } typename std::vector::const_iterator operator[](int y) const { return elems.begin() + (y * w); } static MatrixModulo identity(int idx){ auto res = MatrixModulo(idx, idx); for(int i = 0; i < idx; i++) res[i][i] = 1; return res; } MatrixModulo operator*(const MatrixModulo& r) const { assert(width() == r.height()); auto res = MatrixModulo(h, r.w); for (int i=0; i=i; k--) g[j][k] -= g[j][i] * g[i][k]; } return ans; } int rank() const { MatrixModulo g = *this; int y = 0; for (int d=0; d=d; j--) g[i][j] -= g[i][d] * g[y][j]; y++; } return y; } MatrixModulo linear_equation() const { MatrixModulo g = *this; int y = 0; std::vector> det_var; std::vector rank_var; for (int d=0; d=d; j--) g[i][j] -= g[i][d] * g[y][j]; det_var.push_back(std::make_pair(d,y)); y++; } for (int i=y; i #include #include using namespace std; using i64 = long long; using m32 = atcoder::static_modint<998244353>; #define rep(i,n) for(int i=0; i<(int)(n); i++) int main(){ i64 N; cin >> N; nachia::MatrixModulo G(4,4); G[0][1] = 1; G[0][3] = 1; rep(t,2) G[t][t+2] = 1; rep(p,2) G[p][p] = G[p+2][p] = 1; G = G.pow((N+1)/2); m32 ans = G[0][N%2]; cout << ans.val() << endl; return 0; } struct ios_do_not_sync{ ios_do_not_sync(){ std::ios::sync_with_stdio(false); std::cin.tie(nullptr); } } ios_do_not_sync_instance;