반응형
https://www.acmicpc.net/problem/14173
14173번: Square Pasture
In the example above, the first original rectangle has corners (6,6) and (8,8). The second has corners at (1,8) and (4,9). By drawing a square fence of side length 7 with corners (1,6) and (8,13), the original areas can still be enclosed; moreover, this is
www.acmicpc.net
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | #include <iostream> #include <algorithm> #include <cmath> using namespace std; int main() { int x1,x2,y1,y2; int a1, a2, b1, b2; cin >> x1 >> y1 >> x2 >> y2; cin >> a1 >> b1 >> a2 >> b2; int ans1 = max(a2, x2) - min(a1,x1); int ans2 = max(b2, y2) - min(b1, y1); int ans = max(ans1, ans2); cout << ans * ans << '\n'; } | cs |
'Algorithm' 카테고리의 다른 글
(C++) - 백준(BOJ) 15700번 : 타일 채우기 4 (0) | 2019.12.21 |
---|---|
(C++) - 백준(BOJ) 13752번 : 히스토그램 (0) | 2019.12.21 |
(C++) - 백준(BOJ) 16204번 : 카드뽑기 (0) | 2019.11.21 |
(C++) - 백준(BOJ) 15921번 : 수찬은 마린보이야!! (0) | 2019.11.19 |
(C++) - 백준(BOJ) 14470번 : 전자레인지 (0) | 2019.11.19 |