結果
問題 |
No.314 ケンケンパ
|
ユーザー |
![]() |
提出日時 | 2016-07-09 05:38:45 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 600 bytes |
コンパイル時間 | 227 ms |
コンパイル使用メモリ | 32,512 KB |
実行使用メモリ | 13,568 KB |
最終ジャッジ日時 | 2024-10-13 08:10:34 |
合計ジャッジ時間 | 1,145 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; int dp[111111][2][4]; int solve(int a, int b, int c) { if (dp[a][b][c] >= 0) return dp[a][b][c]; if (a == n) return 1; int 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)); int res = solve(0, 0, 0); printf("%d\n", res); return 0; }