BOJ_단계별로 풀어보기(9단계~)/[8단계] 기본 수학2
[백준 1085] 직사각형에서 탈출
pushback
2021. 7. 28. 10:04
\((x, y)\)가 직사각형 안에 존재하는 점이기 때문에 직사각형의 네 경계선까지 거리는 무리없이 구할 수 있다.
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int x, y, w, h;
cin >> x >> y >> w >> h;
int ans = min({x, w - x, y, h - y});
cout << ans;
return 0;
}