#include #include #include template class ModInt { unsigned v_; static unsigned norm(long long x) { x %= Mod; if (x < 0) x += Mod; return (unsigned)x; } public: ModInt(long long v = 0) : v_(norm(v)) {} unsigned val() const { return v_; } ModInt& operator+=(const ModInt& o) { v_ += o.v_; if (v_ >= Mod) v_ -= Mod; return *this; } friend ModInt operator+(ModInt a, const ModInt& b) { return a += b; } }; using mint = ModInt<1000000007>; static const int S = 8; // 3-bit states std::vector nxt[S]; void build_transitions() { for (int k = 0; k < S; ++k) { for (int j = 0; j < S; ++j) { if ((k & ~j) == 0) { nxt[k].push_back(j); } } } } mint dp[55][S]; int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); int N; std::cin >> N; build_transitions(); // 初始化:第一列所有状态都可能出现(无额外限制时) for (int s = 0; s < S; ++s) { dp[1][s] = 1; } // DP for (int i = 2; i <= N; ++i) { for (int k = 0; k < S; ++k) { if (dp[i - 1][k].val() == 0) continue; for (int j : nxt[k]) { dp[i][j] += dp[i - 1][k]; } } } // 汇总所有状态 mint res = 0; for (int s = 0; s < S; ++s) { res += dp[N][s]; } std::cout << res.val() << "\n"; return 0; }