結果
問題 | No.314 ケンケンパ |
ユーザー |
![]() |
提出日時 | 2016-02-17 09:26:33 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 65 ms / 1,000 ms |
コード長 | 505 bytes |
コンパイル時間 | 468 ms |
コンパイル使用メモリ | 57,028 KB |
実行使用メモリ | 67,252 KB |
最終ジャッジ日時 | 2024-09-22 07:24:36 |
合計ジャッジ時間 | 1,598 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
#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; }