結果
| 問題 | No.44 DPなすごろく |
| ユーザー |
|
| 提出日時 | 2017-07-08 19:33:56 |
| 言語 | C++14 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 474 bytes |
| 記録 | |
| コンパイル時間 | 463 ms |
| コンパイル使用メモリ | 63,872 KB |
| 最終ジャッジ日時 | 2026-05-10 04:43:23 |
| 合計ジャッジ時間 | 1,346 ms |
|
ジャッジサーバーID (参考情報) |
judge1_1 / judge2_0 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp:4:1: error: 'int_least64_t' does not name a type
4 | int_least64_t search(int n, std::vector<int_least64_t>& cache) {
| ^~~~~~~~~~~~~
main.cpp: In function 'int main()':
main.cpp:20:21: error: 'int_least64_t' was not declared in this scope
20 | std::vector<int_least64_t> cache(n, -1);
| ^~~~~~~~~~~~~
main.cpp:20:34: error: template argument 1 is invalid
20 | std::vector<int_least64_t> cache(n, -1);
| ^
main.cpp:20:34: error: template argument 2 is invalid
main.cpp:20:47: error: expression list treated as compound expression in initializer [-fpermissive]
20 | std::vector<int_least64_t> cache(n, -1);
| ^
main.cpp:21:22: error: expected ';' before 'result'
21 | int_least64_t result = search(n, cache);
| ^~~~~~~
| ;
main.cpp:23:22: error: 'result' was not declared in this scope
23 | std::cout << result << std::endl;
| ^~~~~~
ソースコード
#include <iostream>
#include <vector>
int_least64_t search(int n, std::vector<int_least64_t>& cache) {
if (n == 0) return 1;
if (n == 1) return 1;
int_least64_t ret = cache[n - 1];
if (ret >= 0) return ret;
ret = search(n - 2, cache) + search(n - 1, cache);
cache[n - 1] = ret;
return ret;
}
int main()
{
int n;
std::cin >> n;
std::vector<int_least64_t> cache(n, -1);
int_least64_t result = search(n, cache);
std::cout << result << std::endl;
return 0;
}