Baekjoon 14173번 [Square Pasture]

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

 

  • 사용언어: Python (PyPy3)
  • 알고리즘: 수학, 사칙연산

 

문제

 

 


 

코드

 

x1, y1, x2, y2 = map(int, input().split())
x3, y3, x4, y4 = map(int, input().split())
xs = [x1, x2, x3, x4]
ys = [y1, y2, y3, y4]
new_x1, new_x2 = min(xs), max(xs)
new_y1, new_y2 = min(ys), max(ys)
side_length = max(new_x2-new_x1, new_y2-new_y1)
print(side_length*side_length)

 

 

'백준 > USACO bronze 기출' 카테고리의 다른 글

[백준] 14530번 The Lost Cow  (0) 2022.10.03
[백준] 14175번 The Cow-Signal  (0) 2022.10.03
[백준] 15751번 Teleportation  (0) 2022.10.03
[백준] 10675번 Cow Routing  (0) 2022.10.03
[백준] 11970번 Fence Painting  (0) 2022.10.03

+ Recent posts