結果

問題 No.314 ケンケンパ
ユーザー nayutanayuta
提出日時 2019-10-13 01:40:10
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 10 ms / 1,000 ms
コード長 432 bytes
コンパイル時間 1,397 ms
コンパイル使用メモリ 163,872 KB
実行使用メモリ 26,744 KB
最終ジャッジ日時 2023-08-20 03:13:45
合計ジャッジ時間 2,662 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 10 ms
26,584 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 4 ms
7,412 KB
testcase_18 AC 7 ms
15,576 KB
testcase_19 AC 10 ms
26,744 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