PS(Problem Solving)/soleved.ac CLASS
solved.ac class2 백준 1085번(직사각형에서 탈출)
LiaLi_1997
2021. 10. 19. 13:26
핵심로직
- 좌표평면을 생각하면 편하다.
- 4 가지 중 최소값을 가져오면 된다. -> x 와 w 사이의 거리, y 와 h 사이의 거리, x 와 y축 사이의 거리, y 와 x 축 사이의 거리
#include <iostream>
#include <algorithm>
using namespace std;
int x, y, w, h, result;
int main() {
cin >> x >> y >> w >> h;
result = min({x, y, h-y, w-x});
cout << result << endl;
return 0;
}