728x90
9298번: Ant Entrapment
For each case output the line “Case x:” where x is the case number, on a single line, followed by the string “Area” and the area of the fence as a floating-point value and then a comma, followed by a space and then “Perimeter” and the perimeter
www.acmicpc.net
문제 풀이
주어진 입력값 중 x의 최댓값과 x의 최솟값으로 x의 길이를 구하고, y의 최댓값과 y의 최솟값으로 y의 길이를 구해 사각형의 넓이와 둘레를 출력해준다.
정답 코드
import sys
input = sys.stdin.readline
for i in range(1, int(input()) + 1) :
x_lst = []
y_lst = []
for _ in range(int(input())) :
x, y = map(float, input().split())
x_lst.append(x)
y_lst.append(y)
area = (max(x_lst) - min(x_lst)) * (max(y_lst) - min(y_lst))
peri = 2 * ((max(x_lst) - min(x_lst)) + (max(y_lst) - min(y_lst)))
print("Case {:d}: Area {:f}, Perimeter {:f}".format(i, area, peri))
728x90
'Algorithm > PS' 카테고리의 다른 글
[BOJ/백준] 9306 - Practice: Roll Call [python] (0) | 2023.03.24 |
---|---|
[BOJ/백준] 9299 - Math Tutoring [python] (0) | 2023.03.24 |
[BOJ/백준] 9297 - Reducing Improper Fractions [python] (0) | 2023.03.24 |
[BOJ/백준] 9295 - 주사위 [python] (0) | 2023.03.24 |
[BOJ/백준] 9288 - More Dice [python] (0) | 2023.03.24 |