結果

問題 No.314 ケンケンパ
ユーザー zaki_joho
提出日時 2018-12-23 22:20:55
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 78 ms / 1,000 ms
コード長 677 bytes
コンパイル時間 2,550 ms
コンパイル使用メモリ 164,040 KB
実行使用メモリ 57,776 KB
最終ジャッジ日時 2024-09-25 10:39:57
合計ジャッジ時間 2,288 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    vector<vector<ll>> dp(n + 1, vector<ll>(3, 0));
    dp[1][1] = 1;
    for (int i = 2; i <= n; i++)
    {
        dp[i][0] = (dp[i - 1][1] + dp[i - 1][2]) % MOD;
        dp[i][1] = dp[i - 1][0];
        dp[i][2] = dp[i - 1][1];
    }
    ll res = dp[n][0];
    res += dp[n][1];
    res %= MOD;
    res += dp[n][2];
    res %= MOD;
    cout << res << endl;
}
0