結果
問題 | No.314 ケンケンパ |
ユーザー | penguinshunya |
提出日時 | 2019-03-25 13:02:23 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 26 ms / 1,000 ms |
コード長 | 2,641 bytes |
コンパイル時間 | 1,452 ms |
コンパイル使用メモリ | 110,408 KB |
実行使用メモリ | 26,984 KB |
最終ジャッジ日時 | 2024-10-07 21:38:46 |
合計ジャッジ時間 | 2,476 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 24 ms
26,736 KB |
testcase_01 | AC | 7 ms
26,900 KB |
testcase_02 | AC | 7 ms
26,904 KB |
testcase_03 | AC | 8 ms
26,952 KB |
testcase_04 | AC | 7 ms
26,752 KB |
testcase_05 | AC | 8 ms
26,748 KB |
testcase_06 | AC | 7 ms
26,748 KB |
testcase_07 | AC | 7 ms
26,800 KB |
testcase_08 | AC | 8 ms
26,884 KB |
testcase_09 | AC | 8 ms
26,864 KB |
testcase_10 | AC | 7 ms
26,740 KB |
testcase_11 | AC | 7 ms
26,788 KB |
testcase_12 | AC | 7 ms
26,804 KB |
testcase_13 | AC | 7 ms
26,852 KB |
testcase_14 | AC | 8 ms
26,840 KB |
testcase_15 | AC | 8 ms
26,816 KB |
testcase_16 | AC | 8 ms
26,812 KB |
testcase_17 | AC | 9 ms
26,936 KB |
testcase_18 | AC | 17 ms
26,984 KB |
testcase_19 | AC | 26 ms
26,796 KB |
ソースコード
#include <iostream> #include <iomanip> #include <cstdio> #include <cstdlib> #include <cstring> #include <algorithm> #include <string> #include <sstream> #include <complex> #include <vector> #include <list> #include <queue> #include <deque> #include <stack> #include <map> #include <set> #define rep(i, n) for (int i = 0; i < (n); i++) #define rrep(i, n) for (int i = (n) - 1; i >= 0; i--) #define reps(i, n) for (int i = 1; i <= (n); i++) #define repi(i, a, b) for (int i = (a); i < (b); i++) #define all(a) (a).begin(), (a).end() #define bit(b) (1ull << (b)) using namespace std; using i32 = long long; using u32 = unsigned long long; using i64 = long long; using u64 = unsigned long long; using f64 = double; using vi32 = vector<i32>; using vu32 = vector<u32>; using vi64 = vector<i64>; using vu64 = vector<u64>; using vf64 = vector<f64>; using vstr = vector<string>; using vvi32 = vector<vi32>; using vvu32 = vector<vu32>; using vvi64 = vector<vi64>; using vvu64 = vector<vu64>; using vvf64 = vector<vf64>; template<typename T, typename S> void amax(T &x, S y) { if (x < y) x = y; } template<typename T, typename S> void amin(T &x, S y) { if (y < x) x = y; } template<int mod> class modint { public: int x; modint(): x(0) {} modint(int a) { x = a % mod; if (x < 0) x += mod; } modint &operator+=(modint that) { x = (x + that.x) % mod; return *this; } modint &operator-=(modint that) { x = (x + mod - that.x) % mod; return *this; } modint &operator*=(modint that) { x = (long long) x * that.x % mod; return *this; } modint &operator/=(modint that) { return *this *= that.inverse(); } modint operator-() { return modint(-this->x); } friend ostream& operator<<(ostream &out, modint m) { return out << m.x; } modint inverse() { int a = x, b = mod, u = 1, v = 0; while (b) { int t = a / b; a -= t * b; u -= t * v; swap(a, b); swap(u, v); } return modint(u); } #define op(o, p) modint operator o(modint that) { return modint(*this) p that; } op(+, +=) op(-, -=) op(*, *=) op(/, /=) #undef op #define op(o) bool operator o(modint that) const { return x o that.x; } op(==) op(!=) op(<) op(<=) op(>) op(>=) #undef op }; using mint = modint<1000000007>; mint dp[1000010][3][2]; int main() { ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(16); int n; cin >> n; dp[1][1][0] = 1; reps(i, n - 1) rep(j, 3) rep(k, 2) { if (j >= 1) dp[i + 1][0][1] += dp[i][j][k]; if (j == 1) dp[i + 1][2][0] += dp[i][j][k]; if (k == 1) dp[i + 1][1][0] += dp[i][j][k]; } mint ans = 0; rep(j, 3) rep(k, 2) { ans += dp[n][j][k]; } cout << ans << endl; return 0; }