結果

問題 No.314 ケンケンパ
ユーザー sei0osei0o
提出日時 2017-10-16 17:27:10
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 632 bytes
コンパイル時間 743 ms
コンパイル使用メモリ 79,296 KB
実行使用メモリ 5,820 KB
最終ジャッジ日時 2023-08-11 06:54:22
合計ジャッジ時間 3,602 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 4 ms
5,680 KB
testcase_18 RE -
testcase_19 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <queue>
#include <vector>
#include <cmath>
#include <algorithm>
#include <map>
#include <numeric>

using namespace std;
using ll = long long;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;

ll dp[100010][3];

int main() {
    int N;
    cin >> N;

    dp[0][0] = 1;
    for (int 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]; // ケン2回目

        dp[i+1][0] %= MOD;
        dp[i+1][1] %= MOD;
        dp[i+1][2] %= MOD;
    }

    cout << (dp[N][0] + dp[N][1] + dp[N][2]) % MOD << endl;

    return 0;
}
0