結果

問題 No.314 ケンケンパ
ユーザー Naoyk1212Naoyk1212
提出日時 2017-06-14 14:59:01
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 26 ms / 1,000 ms
コード長 550 bytes
コンパイル時間 519 ms
コンパイル使用メモリ 65,128 KB
実行使用メモリ 26,872 KB
最終ジャッジ日時 2023-10-25 01:25:45
合計ジャッジ時間 1,644 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <queue>
#include <map>
using namespace std;
const int mod = 1e9 + 7;

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

    long long dp[n + 10][3];
    for(int i = 0; i < n + 10; i++){
        for(int j = 0; j < 3; j++){
            dp[i][j] = 0;
        }
    }

    dp[0][0] = 1;
    for(int i = 0; i < n; i++){
        dp[i + 1][0] += (dp[i][2] + dp[i][1]) % mod;
        dp[i + 1][1] += dp[i][0] % mod;
        dp[i + 1][2] += dp[i][1] % mod;
    }
    cout << (dp[n][0] + dp[n][1] + dp[n][2]) % mod << endl;
}
0