목차

집으로

ps
링크acmicpc.net/…
출처BOJ
문제 번호1069
문제명집으로
레벨골드 2
분류

애드혹

시간복잡도O(1)
사용한 언어Python
제출기록32976KB / 68ms
최고기록56ms
해결날짜2022/02/17

풀이

코드

"""Solution code for "BOJ 1069. 집으로".

- Problem link: https://www.acmicpc.net/problem/1069
- Solution link: http://www.teferi.net/ps/problems/boj/1069
"""

import math


def main():
    X, Y, D, T = [int(x) for x in input().split()]
    dist = math.sqrt(X * X + Y * Y)

    if D <= T:
        answer = dist
    elif D > dist:
        answer = min(T + T, T + D - dist, dist)
    else:
        jump_count = int(dist / D)
        answer = jump_count * T + min(T, dist - D * jump_count)

    print(answer)


if __name__ == '__main__':
    main()