728x90
반응형
단순 구현 문제이다. 입력을 한 번에 다 받기 위해 stdin.read() 함수를 사용했다.
stdin.read()함수를 몰라서 어제 삽질하다가 결국 못 풀었던 문제인데, 방금 알아서 바로 통과했다.
import sys
nums = list(map(int, sys.stdin.read().split()))
for n in nums:
if n == 0:
break
li = []
for i in range(1, n):
if n % i == 0:
if i not in li:
li.append(i)
if n//i not in li and n//i != n:
li.append(n//i)
if sum(li) == n:
print(f"{n} PERFECT")
elif sum(li) < n:
print(f"{n} DEFICIENT")
else:
print(f"{n} ABUNDANT")
728x90
반응형
'Agorithm > 백준 알고리즘' 카테고리의 다른 글
백준 알고리즘 1392번 노래 악보(python) (0) | 2021.02.17 |
---|---|
백준 알고리즘 1373번 2진수 8진수(python) (0) | 2021.02.17 |
백준 알고리즘 1371번 가장 많은 글자(python) (0) | 2021.02.17 |
백준 알고리즘 1340번 연도 진행바(python) (0) | 2021.02.17 |
백준 알고리즘 1264번 모음의 개수(python) (0) | 2021.02.17 |