結果

問題 No.314 ケンケンパ
ユーザー nayutanayuta
提出日時 2019-10-13 01:40:10
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 20 ms / 1,000 ms
コード長 432 bytes
コンパイル時間 1,905 ms
コンパイル使用メモリ 166,092 KB
実行使用メモリ 26,752 KB
最終ジャッジ日時 2024-11-30 02:41:10
合計ジャッジ時間 2,535 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 20 ms
26,496 KB
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 2 ms
5,248 KB
testcase_03 AC 2 ms
5,248 KB
testcase_04 AC 2 ms
5,248 KB
testcase_05 AC 2 ms
5,248 KB
testcase_06 AC 2 ms
5,248 KB
testcase_07 AC 2 ms
5,248 KB
testcase_08 AC 2 ms
5,248 KB
testcase_09 AC 2 ms
5,248 KB
testcase_10 AC 2 ms
5,248 KB
testcase_11 AC 2 ms
5,248 KB
testcase_12 AC 2 ms
5,248 KB
testcase_13 AC 2 ms
5,248 KB
testcase_14 AC 2 ms
5,248 KB
testcase_15 AC 3 ms
5,248 KB
testcase_16 AC 2 ms
5,248 KB
testcase_17 AC 4 ms
5,760 KB
testcase_18 AC 11 ms
14,720 KB
testcase_19 AC 20 ms
26,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

const int MOD = (int)1e9 + 7;

long long int N;
long long int dp[1010101][3];

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

  cout << (dp[N][0] + dp[N][1] + dp[N][2]) % MOD << endl;

  return 0;
}
0