結果

問題 No.314 ケンケンパ
ユーザー aaaaaaiuaaaaaaiu
提出日時 2019-08-12 21:45:30
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 9 ms / 1,000 ms
コード長 369 bytes
コンパイル時間 2,075 ms
コンパイル使用メモリ 201,656 KB
実行使用メモリ 15,428 KB
最終ジャッジ日時 2023-10-17 14:31:47
合計ジャッジ時間 3,006 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 9 ms
15,228 KB
testcase_01 AC 2 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 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 AC 2 ms
4,348 KB
testcase_17 AC 3 ms
4,880 KB
testcase_18 AC 7 ms
9,316 KB
testcase_19 AC 9 ms
15,428 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
    int mod=1e9+7;
    int n;
    cin>>n;
    int dp[n+1][3]{};
    dp[0][2]=1;
    for (int i=0;i<n;i++) {
        dp[i+1][0]=dp[i][2];
        dp[i+1][1]=dp[i][0];
        dp[i+1][2]=(dp[i][0]+dp[i][1])%mod;
    }
    cout<<((dp[n][0]+dp[n][1])%mod+dp[n][2])%mod<<endl;
    return 0;
}
0