結果

問題 No.314 ケンケンパ
ユーザー d2verbd2verb
提出日時 2016-02-17 09:26:33
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 57 ms / 1,000 ms
コード長 505 bytes
コンパイル時間 1,263 ms
コンパイル使用メモリ 58,140 KB
実行使用メモリ 67,440 KB
最終ジャッジ日時 2023-10-22 06:08:38
合計ジャッジ時間 1,623 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 57 ms
66,556 KB
testcase_01 AC 7 ms
15,360 KB
testcase_02 AC 7 ms
15,360 KB
testcase_03 AC 7 ms
15,360 KB
testcase_04 AC 6 ms
15,360 KB
testcase_05 AC 6 ms
15,360 KB
testcase_06 AC 6 ms
15,360 KB
testcase_07 AC 6 ms
15,360 KB
testcase_08 AC 7 ms
15,360 KB
testcase_09 AC 6 ms
15,360 KB
testcase_10 AC 6 ms
15,372 KB
testcase_11 AC 6 ms
15,380 KB
testcase_12 AC 6 ms
15,388 KB
testcase_13 AC 6 ms
15,408 KB
testcase_14 AC 6 ms
15,652 KB
testcase_15 AC 7 ms
15,876 KB
testcase_16 AC 7 ms
16,672 KB
testcase_17 AC 12 ms
20,564 KB
testcase_18 AC 30 ms
40,272 KB
testcase_19 AC 56 ms
67,440 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;

int n;
int memo[1000000][3];

int solve(int t, int k) {
  if (t >= n) return 1;
  if (memo[t][k] != -1) return memo[t][k];
  int ret = 0;
  if (k + 1 < 3) ret += solve(t + 1, k + 1) % 1000000007;
  if (k != 0)    ret += solve(t + 1, 0) % 1000000007;
  return memo[t][k] = ret;
}

int main(void) {
  cin >> n;
  for (int i = 0; i < 1000000; i++) {
    for (int j = 0; j < 3; j++) memo[i][j] = -1;
  }
  cout << solve(0, 0) << endl;
  return 0;
}
0