結果

問題 No.314 ケンケンパ
ユーザー ldsybldsyb
提出日時 2024-02-24 14:45:52
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 70 ms / 1,000 ms
コード長 538 bytes
コンパイル時間 6,198 ms
コンパイル使用メモリ 312,036 KB
実行使用メモリ 58,020 KB
最終ジャッジ日時 2024-02-24 14:46:00
合計ジャッジ時間 7,002 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 67 ms
57,096 KB
testcase_01 AC 1 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 1 ms
6,676 KB
testcase_04 AC 1 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 AC 2 ms
6,676 KB
testcase_07 AC 2 ms
6,676 KB
testcase_08 AC 2 ms
6,676 KB
testcase_09 AC 2 ms
6,676 KB
testcase_10 AC 1 ms
6,676 KB
testcase_11 AC 2 ms
6,676 KB
testcase_12 AC 2 ms
6,676 KB
testcase_13 AC 2 ms
6,676 KB
testcase_14 AC 2 ms
6,676 KB
testcase_15 AC 3 ms
6,676 KB
testcase_16 AC 4 ms
6,676 KB
testcase_17 AC 9 ms
8,832 KB
testcase_18 AC 35 ms
29,496 KB
testcase_19 AC 70 ms
58,020 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using namespace chrono;
#if __has_include(<atcoder/all>)
#include <atcoder/all>
using namespace atcoder;
#endif

int main()
{
    int64_t n;
    cin >> n;

    using mint = modint1000000007;

    vector dp(n + 1, vector(3, mint(0)));

    dp[0][0] = 1;
    for (int64_t i = 0; i < n; i++)
    {
        dp[i + 1][0] += dp[i][1] + dp[i][2];
        dp[i + 1][1] += dp[i][0];
        dp[i + 1][2] += dp[i][1];
    }

    cout << (dp[n][0] + dp[n][1] + dp[n][2]).val() << endl;

    return 0;
}
0