結果

問題 No.314 ケンケンパ
ユーザー tadanoningentadanoningen
提出日時 2021-01-21 00:54:51
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 81 ms / 1,000 ms
コード長 513 bytes
コンパイル時間 771 ms
コンパイル使用メモリ 76,192 KB
実行使用メモリ 57,796 KB
最終ジャッジ日時 2023-08-25 04:31:12
合計ジャッジ時間 3,432 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
57,576 KB
testcase_01 AC 72 ms
57,748 KB
testcase_02 AC 73 ms
57,764 KB
testcase_03 AC 72 ms
57,604 KB
testcase_04 AC 73 ms
57,656 KB
testcase_05 AC 73 ms
57,688 KB
testcase_06 AC 72 ms
57,508 KB
testcase_07 AC 73 ms
57,740 KB
testcase_08 AC 72 ms
57,608 KB
testcase_09 AC 73 ms
57,604 KB
testcase_10 AC 73 ms
57,796 KB
testcase_11 AC 73 ms
57,512 KB
testcase_12 AC 73 ms
57,652 KB
testcase_13 AC 72 ms
57,520 KB
testcase_14 AC 73 ms
57,752 KB
testcase_15 AC 72 ms
57,664 KB
testcase_16 AC 74 ms
57,632 KB
testcase_17 AC 73 ms
57,580 KB
testcase_18 AC 77 ms
57,512 KB
testcase_19 AC 80 ms
57,504 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>

using namespace std;
using ll = long long;

const ll mod = 1000000007;

vector<vector<ll>> dp(1000005,vector<ll>(3));

int main(){
    ll n;
    cin >> n;
    
    dp[0][0] = 1;
    for(int i=1;i <= n;i++){
        for(int j=0;j < 3;j++){
            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 ans = (dp[n][0] + dp[n][1] + dp[n][2]) % mod;

    cout << ans << endl;
    return 0;
}
0