結果

問題 No.314 ケンケンパ
ユーザー syunsukesyunsuke
提出日時 2019-04-23 00:05:50
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 25 ms / 1,000 ms
コード長 454 bytes
コンパイル時間 1,325 ms
コンパイル使用メモリ 53,980 KB
実行使用メモリ 26,880 KB
最終ジャッジ日時 2024-04-20 10:02:33
合計ジャッジ時間 1,680 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
26,752 KB
testcase_01 AC 18 ms
26,752 KB
testcase_02 AC 18 ms
26,624 KB
testcase_03 AC 18 ms
26,752 KB
testcase_04 AC 18 ms
26,752 KB
testcase_05 AC 18 ms
26,880 KB
testcase_06 AC 19 ms
26,880 KB
testcase_07 AC 18 ms
26,752 KB
testcase_08 AC 18 ms
26,752 KB
testcase_09 AC 18 ms
26,880 KB
testcase_10 AC 18 ms
26,880 KB
testcase_11 AC 18 ms
26,880 KB
testcase_12 AC 18 ms
26,752 KB
testcase_13 AC 18 ms
26,752 KB
testcase_14 AC 19 ms
26,752 KB
testcase_15 AC 18 ms
26,752 KB
testcase_16 AC 18 ms
26,880 KB
testcase_17 AC 19 ms
26,880 KB
testcase_18 AC 21 ms
26,752 KB
testcase_19 AC 25 ms
26,880 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    long long dp[1000005][3];
    int N;
    cin>>N;
    for(int i=0;i<=N;i++){
        for(int j=0;j<=2;j++){
            dp[i][j]=0;
        }
    }
    dp[1][0]=1;
    for(int i=2;i<=N;i++){
        dp[i][0]=dp[i-1][2];
        dp[i][1]=dp[i-1][0];
        dp[i][2]=(dp[i-1][0]+dp[i-1][1])%(1000000007);
    }
    cout<<(dp[N][0]+dp[N][1]+dp[N][2])%(1000000007)<<endl;
}
0