728x90
9723번: Right Triangle
For each test case, the output contains a line in the format Case #x: M, where x is the case number (starting from 1) and M is “YES” when the given triangle is a right triangle or “NO” otherwise. Note that the quotes are not required to be outputte
www.acmicpc.net
문제 풀이
테스트마다 입력값들이 직각삽각형이 가능한 지 피타고라스 정리를 통해 판단한다.
정답 코드
for i in range(1, int(input()) + 1) :
triangle = [i ** 2 for i in [*map(int, input().split())]]
if max(triangle) == sum(triangle) - max(triangle) : print(f"Case #{i}: YES")
else : print(f"Case #{i}: NO")
728x90
'Algorithm > PS' 카테고리의 다른 글
[BOJ/백준] 9771 - Word Searching [python] (0) | 2023.03.27 |
---|---|
[BOJ/백준] 9724 - Perfect Cube [python] (0) | 2023.03.27 |
[BOJ/백준] 9713 - Sum of Odd Sequence [python] (0) | 2023.03.27 |
[BOJ/백준] 9699 - RICE SACK [python] (0) | 2023.03.27 |
[BOJ/백준] 9698 - SAHUR & IMSA’ [python] (0) | 2023.03.27 |