본문 바로가기
Beakjoon&프로그래머스/파이썬

[백준/파이썬] 22421번 Koto Municipal Subway

by 현장 2024. 10. 26.

-Code

from math import sqrt

while True:
    res = 100000
    d, e = map(int, input().split())

    if d == e == 0:
        break

    for i in range(d):
        now_price = abs(sqrt(i ** 2 + (d - i) ** 2) - e)
        res = min(res, now_price)

    print(f"{res:.4f}")