728x90
9776번: Max Volume
The first line of the input contains a positive integer n (1 ≤ n ≤ 100) which is the number of figures. The n following lines contain the description of each figure. In case of a cone, the line begins with letter C and followed by 2 values: r and h res
www.acmicpc.net
문제 풀이
입력값은 구, 원기둥, 원뿔로 들어오게 되는데, 각각의 부피를 구해준 뒤, 가장 부피가 큰 값을 출력해준다.
정답 코드
pi = 3.14159
ans = []
for _ in range(int(input())) :
lst = input().split()
if lst[0] == "S" :
ans.append((4 / 3) * pi * (float(lst[1]) ** 3))
elif lst[0] == "C" :
ans.append((1 / 3) * pi * (float(lst[1]) ** 2) * float(lst[2]))
else :
ans.append(pi * (float(lst[1]) ** 2) * float(lst[2]))
print("{:.3f}".format(max(ans)))
728x90
'Algorithm > PS' 카테고리의 다른 글
[BOJ/백준] 9838 - XMAX [python] (0) | 2023.03.27 |
---|---|
[BOJ/백준] 9783 - Easy Encryption [python] (0) | 2023.03.27 |
[BOJ/백준] 9773 - ID Key [python] (0) | 2023.03.27 |
[BOJ/백준] 9771 - Word Searching [python] (0) | 2023.03.27 |
[BOJ/백준] 9724 - Perfect Cube [python] (0) | 2023.03.27 |