結果

問題 No.314 ケンケンパ
ユーザー aa
提出日時 2016-07-09 05:40:12
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 616 bytes
コンパイル時間 334 ms
コンパイル使用メモリ 33,536 KB
実行使用メモリ 17,716 KB
最終ジャッジ日時 2024-04-21 09:17:55
合計ジャッジ時間 1,012 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 7 ms
10,624 KB
testcase_02 AC 7 ms
10,624 KB
testcase_03 AC 5 ms
10,624 KB
testcase_04 AC 6 ms
10,672 KB
testcase_05 AC 6 ms
10,752 KB
testcase_06 AC 7 ms
10,624 KB
testcase_07 AC 6 ms
10,624 KB
testcase_08 AC 6 ms
10,740 KB
testcase_09 AC 7 ms
10,752 KB
testcase_10 AC 6 ms
10,624 KB
testcase_11 AC 6 ms
10,752 KB
testcase_12 AC 7 ms
10,752 KB
testcase_13 AC 6 ms
10,864 KB
testcase_14 AC 7 ms
11,136 KB
testcase_15 AC 6 ms
11,380 KB
testcase_16 AC 7 ms
12,412 KB
testcase_17 AC 11 ms
16,896 KB
testcase_18 WA -
testcase_19 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>

using namespace std;

const int mod = 1e9+7;
int n;
long long dp[111111][2][4];

long long solve(int a, int b, int c) {
  if (dp[a][b][c] >= 0) return dp[a][b][c];
  if (a == n) return 1;
  long long res = 0;
  if (b == 0) {
    if (c < 2) {
      res = (res+solve(a+1, 0, c+1))%mod;
    }
    if (c > 0) {
      res = (res+solve(a+1, 1, 0))%mod;
    }
  } else {
    res = (res+solve(a+1, 0, c+1))%mod;
  }
  return dp[a][b][c] = res;
}

int main(void) {
  scanf("%d", &n);
  memset(dp, -1, sizeof(dp));
  long long res = solve(0, 0, 0);
  printf("%lld\n", res);
  return 0;
}
0