結果
問題 | No.314 ケンケンパ |
ユーザー |
![]() |
提出日時 | 2016-07-09 05:39:13 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 610 bytes |
コンパイル時間 | 277 ms |
コンパイル使用メモリ | 32,768 KB |
実行使用メモリ | 17,140 KB |
最終ジャッジ日時 | 2024-10-13 08:10:37 |
合計ジャッジ時間 | 1,078 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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));int res = solve(0, 0, 0);printf("%lld\n", res);return 0;}