結果

問題 No.314 ケンケンパ
ユーザー suika_psuika_p
提出日時 2019-10-03 00:07:40
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 35 ms / 1,000 ms
コード長 1,638 bytes
コンパイル時間 1,734 ms
コンパイル使用メモリ 163,144 KB
実行使用メモリ 26,880 KB
最終ジャッジ日時 2024-04-14 09:01:34
合計ジャッジ時間 2,759 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
26,496 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 AC 2 ms
6,944 KB
testcase_13 AC 2 ms
6,940 KB
testcase_14 AC 3 ms
6,944 KB
testcase_15 AC 2 ms
6,944 KB
testcase_16 AC 3 ms
6,944 KB
testcase_17 AC 6 ms
6,944 KB
testcase_18 AC 17 ms
14,720 KB
testcase_19 AC 35 ms
26,880 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }

ll dp[1000010][3];
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n; cin >> n;
    dp[0][0] = 1;
    rep(i, n) {
        rep(j, 3) {
            if (j == 0) {
                dp[i+1][1] += dp[i][0];
                dp[i+1][1] %= mod;
            } else if (j == 1) {
                dp[i+1][0] += dp[i][1];
                dp[i+1][0] %= mod;
                dp[i+1][2] += dp[i][1];
                dp[i+1][2] %= mod;
            } else if (j == 2) {
                dp[i+1][0] += dp[i][2];
                dp[i+1][0] %= mod;
            }
        }
    }
    ll ans = 0;
    rep(i, 3) {
        ans += dp[n][i];
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}
0