폴더 분리

This commit is contained in:
2026-02-23 11:14:50 +09:00
parent 4aebd20cf5
commit 0e8e68d12f
45 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,44 @@
# 삼각형과 세 변
import sys
input = sys.stdin.readline
CHECK = {0: "Invalid", 1: "Scalene", 2: "Isosceles", 3: "Equilateral"}
def check_triangle(a, b, c):
if a == b and b == c:
return 3
lst = sorted([a, b, c], reverse=True)
if lst[0] >= lst[1] + lst[2]:
return 0
if a != b and b != c and c != a:
return 1
else:
return 2
def solution():
while 1:
a, b, c = map(int, input().rstrip().split())
if a+b+c == 0:
break
result = check_triangle(a, b, c)
print(CHECK.get(result, 0))
return
solution()
"""
걸린 시간: 30분? (함수 나누고, 더 빠른 거 생각해보려다 늦어짐)
해설: 셋 다 무조건 양수로 들어오는데 0, 0, 0이면 끝나므로 더했을 때 0이면 끝내도록 메인함수를 설계했다.
check 함수에서는 0,1,2,3 중에 값을 직접 확인하는 함수인데, 셋 다 같은 경우가 가장 쉽기 때문에 1번으로 체크하였고,
그 다음은 삼각형의 조건인 '제일 큰 변이 나머지 두 변의 합보다 작아야 된다'를 체크하기 위해 정렬하고, 미리 걸러서 invliad를 확인하였다.
이때, 1,2번 길이가 같던, 2,3번 길이가 같던 어떤 상황이든 상관없이 정렬하고, 1 >= 2+3 하면 된다.
마지막으로 1: "Scalene", 2: "Isosceles"를 거를 때는 두 개가 같은 것이 있냐를 알아보는 것보다 셋 다 다른 것을 알아보는게 더 빠르기 때문에
if else로 처리했다. (2는 a=b and b=!c 와 a!=b!=c)
"""