結果

問題 No.2416 vs Slime
ユーザー Kabocha13
提出日時 2023-08-12 14:35:24
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
RE  
実行時間 -
コード長 477 bytes
コンパイル時間 151 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 11,136 KB
最終ジャッジ日時 2024-11-19 20:15:29
合計ジャッジ時間 2,361 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample RE * 1
other RE * 37
権限があれば一括ダウンロードができます

ソースコード

diff #

def min_attacks_to_defeat_slime(H, a):
    # Base case: if the strength of the slime is less than or equal to 0, no attack needed
    if H <= 0:
        return 0
    # Recursively attack two new slimes with health H//a
    return 1 + min(min_attacks_to_defeat_slime(H // a, a), min_attacks_to_defeat_slime(H // a + (H % a), a))

H,a = map(int,input().split())

result = min_attacks_to_defeat_slime(H, a)
print("Minimum attacks to defeat a slime with strength", H, ":", result)
0