코드
#include <iostream>
using namespace std;
int main(){
int x, y, w, h;
cin >> x >> y >> w >> h;
int temp1, temp2, ans;
if(x < y) temp1 = x;
else temp1 = y;
if(w-x < h-y) temp2 = w-x;
else temp2 = h-y;
if(temp1 < temp2) ans = temp1;
else ans = temp2;
cout << ans;
return 0;
}
알게된 점
그림을 보면 이해가 쉽다.
x, y, h-y, w-x중에 최소값을 구하면 된다.
'하루하나코딩' 카테고리의 다른 글
백준 1436 : 영화감독 숌 c++ (0) | 2023.03.29 |
---|---|
백준 1259 : 팰린드롬수 c++ (0) | 2023.03.29 |
백준 1018 : 체스판 다시 칠하기 c++ (0) | 2023.03.28 |
Github 업로드 시작 (0) | 2023.03.28 |
백준 1759 : 암호만들기 c++ (0) | 2023.03.06 |