[Day_27] 백준 5073 삼각형과 세 변_파이썬

LUNA·2023년 3월 7일
0

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

코드

import sys

while(True):
    t=list(map(int,input().split()))
    t.sort()
    d=set(t)
    
    if t[0]==0 and t[1]==0 and t[2]==0:
        break
    if t[0]==t[1]==t[2]:
        print("Equilateral")
    if t[0]+t[1]>t[2]:
        if len(d)==2:
            print("Isosceles")
        elif len(d)==3:
            print("Scalene")
    else:
        print("Invalid")

set

중복되는 요소 빼주기

두 변만 같다는것은 중복되는 요소를 빼고나면 2개가 남는다는 의미 이기 때문에
중복 제거된 리스트를 d로 저장했고, 그 d의 길이로 삼각형을 판별하였음

profile
Happiness

0개의 댓글