Recent Posts
Notice
No Rules Rules
직사각형에서 탈출 (feat. 백준, 1085번) 본문
728x90
반응형
직사각형에서 탈출
https://www.acmicpc.net/problem/1085
반응형
// woohyeon.kim
// https://www.acmicpc.net/problem/1085
#include <iostream>
using namespace std;
int main() {
ios::sync_with_stdio(false), cin.tie(NULL);
register int x, y, w, h;
cin >> x >> y >> w >> h;
register int ans = 1000, start_x = 0, start_y = 0, end_x = w, end_y = h;
ans = min(ans, abs(start_x - x));
ans = min(ans, abs(start_y - y));
ans = min(ans, abs(end_x - x));
ans = min(ans, abs(end_y - y));
cout << ans;
return 0;
}
// *&)*@*
- 주어진 (x,y)에서 (0,0) 까지 x와 y 각각에 대한 최소값을 구해줍니다.
- 주어진 (x,y)에서 (w,h) 까지 x와 y 각각에 대한 최소값을 구해줍니다.
- 위에서 구한 두 최소값 중 최소값을 출력합니다.
728x90
반응형
'생활 > 코테' 카테고리의 다른 글
직각삼각형 (feat. 백준, 4153번) (0) | 2022.08.03 |
---|---|
네 번째 점 (feat. 백준, 3009번) (0) | 2022.08.03 |
서로 다른 부분 문자열의 개수 (feat. 백준, 11478번) (0) | 2022.08.03 |
대칭 차집합 (feat. 백준, 1269번) (0) | 2022.08.03 |
듣보잡 (feat. 백준, 1764번) (0) | 2022.08.03 |
Comments