알고리즘(python)/수학

[Python]수학2 백준 4153

개발일기 2019. 12. 21. 14:36
반응형

문제

https://www.acmicpc.net/problem/4153



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import sys
 
 
while(1):
 
    length=list(map(int,sys.stdin.readline().split()))
    #정렬
    if length[0]*length[1]*length[2]==0:
        break
    max=0
    for i in length:    #빗변이 될 변을 찾는다.
        if max<i:
            max=i
 
    length.remove(max)  #배열에서 제거
    if length[0]**2+length[1]**2==max**2:  #피타고라스의 정리
        print('right')
    else:
        print('wrong')
 

cs



피타고라스의 정리를 안다면 쉽게 구현할수 있다.

https://ko.wikipedia.org/wiki/%ED%94%BC%ED%83%80%EA%B3%A0%EB%9D%BC%EC%8A%A4_%EC%A0%95%EB%A6%AC


반응형