結果

問題 No.314 ケンケンパ
ユーザー suakiisuakii
提出日時 2019-04-19 11:06:17
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 39 ms / 1,000 ms
コード長 357 bytes
コンパイル時間 1,396 ms
コンパイル使用メモリ 159,708 KB
実行使用メモリ 11,372 KB
最終ジャッジ日時 2023-10-23 17:24:01
合計ジャッジ時間 2,892 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
11,240 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 1 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 1 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 3 ms
4,348 KB
testcase_17 AC 5 ms
4,372 KB
testcase_18 AC 19 ms
7,300 KB
testcase_19 AC 39 ms
11,372 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
int main() {
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    ll dp[n+1];
    dp[0] = 1;
    dp[1] = 1;
    dp[2] = 2;

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





    return 0;
}

0