백준 1069 - 집으로 (파이썬)
Updated:
6가지 경우의 수가 있습니다.
d가 총 길이보다 작거나 같은 경우
- 최대한 갈 수 있는 만큼 점프한 후 걸어간다
- 일직선이 아닌 비스듬히 가다가 한번 꺾는다
- 한번에 점프해서 간다
d가 총 길이보다 큰 경우
- 점프한 후 돌아서 걸어간다
- 일직선이 아닌 비스듬히 꺾어서 간다
- 걸어간다
import sys
input = sys.stdin.readline
x, y, d, t = map(int, input().split())
distance = (x ** 2 + y ** 2) ** 0.5
if distance >= d:
ans = min(t * (distance // d) + distance % d, t * (distance // d + 1), distance)
else:
ans = min(t + (d - distance), 2 * t, distance)
print(ans)