https://www.acmicpc.net/problem/1085
1085번: 직사각형에서 탈출
한수는 지금 (x, y)에 있다. 직사각형의 왼쪽 아래 꼭짓점은 (0, 0)에 있고, 오른쪽 위 꼭짓점은 (w, h)에 있다. 직사각형의 경계선까지 가는 거리의 최솟값을 구하는 프로그램을 작성하시오.
www.acmicpc.net
1
2
3
4
5
6
7
|
x, y, w, h = map(int, input().split())
dis_list = []
dis_list.append(w - x)
dis_list.append(x)
dis_list.append(h - y)
dis_list.append(y)
print(min(dis_list))
|
cs |
'Algorithm > Greedy, Implementation' 카테고리의 다른 글
[Python] 백준 #7568 덩치 (0) | 2022.02.26 |
---|---|
[Python] 백준 #1874 스택 수열 (2) | 2021.06.23 |
[Python] 백준 #1181 단어 정렬 (0) | 2021.06.21 |