물먹는산세베리아

[BOJ] 1085번: 직사각형에서 탈출 본문

Algorithm/백준

[BOJ] 1085번: 직사각형에서 탈출

suntall 2021. 2. 23. 01:21
#include <iostream>
using namespace std;

int main() {
	int x, y, w, h;
	cin >> x >> y >> w >> h;
	x = x > w-x ? w-x : x;
	//cout << "x=" << x << endl;
	y = y > h-y ? h-y : y;
	//cout << "y=" << y << endl;
	int answer = 0;
	answer = x > y ? y : x;
	cout << answer;
}

그냥 x, y, w-x, h-y 중에 최소 구함

'Algorithm > 백준' 카테고리의 다른 글

[BOJ] 4153번: 직사각형 C++  (0) 2021.02.28
[BOJ]1193번: 분수찾기  (0) 2021.02.15
[BOJ] 2775번: 부녀회장이 될테야  (0) 2021.02.14