結果
| 問題 |
No.23 技の選択
|
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2016-03-03 02:01:52 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 963 bytes |
| コンパイル時間 | 599 ms |
| コンパイル使用メモリ | 83,668 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-28 16:51:17 |
| 合計ジャッジ時間 | 1,541 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 33 |
ソースコード
/* -*- coding: utf-8 -*-
*
* 23.cc: No.23 技の選択 - yukicoder
*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
using namespace std;
/* constant */
const int MAX_H = 10000;
/* typedef */
/* global variables */
double dp[MAX_H + 1];
/* subroutines */
/* main */
int main() {
int h, a, d;
cin >> h >> a >> d;
// e[x] = 1 + e[x + a]
// e[x] = 1 + e[x]/3 + 2*e[x + d]*2/3
// -> 3*e[x] = 3 + e[x] + 2*e[x + d]
// -> 2*e[x] = 3 + 2*e[x + d]
// -> e[x] = 1.5 + e[x + d]
dp[h] = 0.0;
for (int i = h - 2; i >= 0; i--) {
double d0 = 1 + dp[min(i + a, h)];
double d1 = 1.5 + dp[min(i + d, h)];
dp[i] = min(d0, d1);
}
printf("%.1lf\n", dp[0]);
return 0;
}
tnakao0123