Baekjoon 15751번 [Teleportation]
https://www.acmicpc.net/problem/15751
15751번: Teleportation
The first and only line of input contains four space-separated integers: $a$ and $b$, describing the start and end locations, followed by $x$ and $y$, describing the teleporter. All positions are integers in the range $0 \ldots 100$, and they are not neces
www.acmicpc.net
- 사용언어: Python (PyPy3)
- 알고리즘: 수학, 구현, 사칙연산
문제
코드
a, b, x, y = map(int, input().split())
a, b = min(a, b), max(a, b)
x, y = min(x, y), max(x, y)
distance = b-a
teleporter = abs(x-a)+abs(y-b)
ans = min(distance, teleporter)
print(ans)
'백준 > USACO bronze 기출' 카테고리의 다른 글
[백준] 14530번 The Lost Cow (0) | 2022.10.03 |
---|---|
[백준] 14175번 The Cow-Signal (0) | 2022.10.03 |
[백준] 10675번 Cow Routing (0) | 2022.10.03 |
[백준] 11970번 Fence Painting (0) | 2022.10.03 |
[백준] 14173번 Square Pasture (0) | 2022.10.02 |