結果

問題 No.314 ケンケンパ
ユーザー Yuki InoueYuki Inoue
提出日時 2023-12-19 12:56:28
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 588 bytes
コンパイル時間 3,024 ms
コンパイル使用メモリ 244,664 KB
実行使用メモリ 26,840 KB
最終ジャッジ日時 2023-12-19 12:56:33
合計ジャッジ時間 4,511 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 60 ms
26,444 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 WA -
testcase_04 AC 2 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 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 30 ms
14,616 KB
testcase_19 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
ll INF = 1e18;
ll MOD = 1e9 + 7;

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

    ll dp[N+1][3];
    rep(i,0,N+1) rep(j,0,3) dp[i][j] = 0;
    dp[0][0] = 1;

    rep(i,1,N+1) rep(j,0,3){
        if(j-1>=0){
            dp[i][j] += dp[i-1][j-1];
        }
        else{
            dp[i][0] += (dp[i-1][1] + dp[i-1][2])%MOD;
        }
        dp[i][j] %= MOD;
    }

    cout << dp[N][0] + dp[N][1] + dp[N][2] << endl;
}
0