문제 링크
https://www.acmicpc.net/problem/4153
4153번: 직각삼각형
입력은 여러개의 테스트케이스로 주어지며 마지막줄에는 0 0 0이 입력된다. 각 테스트케이스는 모두 30,000보다 작은 양의 정수로 주어지며, 각 입력은 변의 길이를 의미한다.
www.acmicpc.net
풀이
- 피타고라스 정리 사용해서 직각삼각형인지 판단
while True :
data = list(map(int,input().split()))
# 가장 긴 길이가 빗변
data = sorted(data)
a,b,c = map(int,data)
if a== 0 and b == 0 and c==0:
break
# 하나라도 0이면 삼각형이 될 수 없음
if a== 0 or b == 0 or c==0:
print('wrong')
continue
if c*c == a*a + b*b:
print('right')
else:
print('wrong')
'개발 > algorithm' 카테고리의 다른 글
[백준 9012번] 괄호 - python (0) | 2022.02.12 |
---|---|
[백준 7568번] 덩치 - python (0) | 2022.02.12 |
[백준 2839번] 설탕 배달 - python (0) | 2022.02.12 |
[백준 2805번] 나무 자르기 - python (0) | 2022.02.12 |
[백준 2798번] 블랙잭 - python (0) | 2022.02.12 |