結果
| 問題 | No.23 技の選択 | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2015-08-30 22:53:35 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                CE
                                 
                            (最新) 
                                AC
                                 
                            (最初) | 
| 実行時間 | - | 
| コード長 | 485 bytes | 
| コンパイル時間 | 509 ms | 
| コンパイル使用メモリ | 51,780 KB | 
| 最終ジャッジ日時 | 2024-11-14 19:09:51 | 
| 合計ジャッジ時間 | 1,239 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge1 | 
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
            
            
            
            
            ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp:6:1: error: ‘vector’ does not name a type
    6 | vector<double> dp;
      | ^~~~~~
main.cpp: In function ‘double nya(int)’:
main.cpp:10:6: error: ‘dp’ was not declared in this scope; did you mean ‘d’?
   10 |   if(dp[damage] != inf) { return dp[damage]; }
      |      ^~
      |      d
main.cpp:11:28: error: ‘dp’ was not declared in this scope; did you mean ‘d’?
   11 |   if(damage >= h) { return dp[damage] = 0; }
      |                            ^~
      |                            d
main.cpp:14:10: error: ‘dp’ was not declared in this scope; did you mean ‘d’?
   14 |   return dp[damage] = min(r1, r2);
      |          ^~
      |          d
main.cpp: In function ‘int main()’:
main.cpp:19:3: error: ‘dp’ was not declared in this scope; did you mean ‘d’?
   19 |   dp.assign(h+10, inf);
      |   ^~
      |   d
main.cpp:18:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   18 |   scanf("%d%d%d", &h, &a, &d);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~
            
            ソースコード
#include <iostream>
#include <algorithm>
using namespace std;
const int inf = 987654321;
vector<double> dp;
int h, a, d;
double nya(int damage) {
  if(dp[damage] != inf) { return dp[damage]; }
  if(damage >= h) { return dp[damage] = 0; }
  double r1 = nya(damage + a) + 1,
         r2 = nya(damage + d) + 3. / 2;
  return dp[damage] = min(r1, r2);
}
int main(void) {
  scanf("%d%d%d", &h, &a, &d);
  dp.assign(h+10, inf);
  double res = nya(0);
  printf("%lf\n", res);
  return 0;
}
            
            
            
        