結果

問題 No.314 ケンケンパ
ユーザー shossiissohsshossiissohs
提出日時 2018-01-11 00:13:23
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 18 ms / 1,000 ms
コード長 363 bytes
コンパイル時間 1,163 ms
コンパイル使用メモリ 143,640 KB
実行使用メモリ 26,948 KB
最終ジャッジ日時 2023-08-25 10:43:18
合計ジャッジ時間 2,172 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
ll mod = 1e9 + 7;

ll dp[1000001][3];

int main() {
  int n;
  cin >> n;
  dp[0][0] = 1;
  for(int i = 0; i < n; i++) {
    dp[i+1][0] = (dp[i][1] + dp[i][2]) % mod;
    dp[i+1][1] = dp[i][0];
    dp[i+1][2] = dp[i][1];
  }

  cout << ((dp[n][0] + dp[n][1]) % mod + dp[n][2]) % mod << endl;
}
0