[PYTHON] 백준 1085 - 직사각형에서 탈출

이또삐(이민혁)·2023년 4월 13일

CODINGTEST

목록 보기
6/96
post-thumbnail

성능 요약

메모리: 113112 KB, 시간: 112 ms

분류

수학, 기하학

문제 설명

한수는 지금 (x, y)에 있다. 직사각형은 각 변이 좌표축에 평행하고, 왼쪽 아래 꼭짓점은 (0, 0), 오른쪽 위 꼭짓점은 (w, h)에 있다. 직사각형의 경계선까지 가는 거리의 최솟값을 구하는 프로그램을 작성하시오.

입력

첫째 줄에 x, y, w, h가 주어진다.

출력

첫째 줄에 문제의 정답을 출력한다.

#https://www.acmicpc.net/problem/1085
#직사각형에서 탈출
#1085

import sys
input = sys.stdin.readline

x, y, w, h = map(int, input().split())

# print(x)
# print(y)
# print(w)
# print(h)

print(min(x,y,w-x,h-y))
#https://www.acmicpc.net/problem/1085
#직사각형에서 탈출
#1085

import sys
input = sys.stdin.readline

x, y, w, h = map(int, input().split())

def fun(x, y, w, h):
    global result

    result = min(x, y, w-x, h-y)

    return print(result)

fun(x, y, w, h)
profile
해보자! 게임 클라 개발자!

0개의 댓글