結果
| 問題 |
No.23 技の選択
|
| コンテスト | |
| ユーザー |
lam6er
|
| 提出日時 | 2025-03-20 21:09:58 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 48 ms / 5,000 ms |
| コード長 | 739 bytes |
| コンパイル時間 | 690 ms |
| コンパイル使用メモリ | 82,884 KB |
| 実行使用メモリ | 61,692 KB |
| 最終ジャッジ日時 | 2025-03-20 21:10:44 |
| 合計ジャッジ時間 | 2,939 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 33 |
ソースコード
H, A, D = map(int, input().split())
# Initialize DP array, dp[h] represents the minimal expected attacks to reduce health h to 0
max_h = H
dp = [float('inf')] * (max_h + 1)
dp[0] = 0.0
for h in range(1, max_h + 1):
# Calculate regular attack's expectation
if h <= A:
regular = 1.0
else:
regular = 1.0 + dp[h - A]
# Calculate special attack's expectation
if h <= D:
special = 1.5
else:
special = (3.0 + 2.0 * dp[h - D]) / 2.0
# Choose the minimal expectation
dp[h] = min(regular, special)
# Output with precision handling to meet the problem's requirements
print("{0:.10f}".format(dp[H]).rstrip('0').rstrip('.') if '.' in "{0:.10f}".format(dp[H]) else int(dp[H]))
lam6er