結果
| 問題 |
No.314 ケンケンパ
|
| コンテスト | |
| ユーザー |
a
|
| 提出日時 | 2016-07-09 05:40:12 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 616 bytes |
| コンパイル時間 | 241 ms |
| コンパイル使用メモリ | 32,640 KB |
| 実行使用メモリ | 17,152 KB |
| 最終ジャッジ日時 | 2024-10-13 08:10:38 |
| 合計ジャッジ時間 | 964 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 14 WA * 3 |
ソースコード
#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;
}
a