https://www.acmicpc.net/problem/9506
#Solution
100,000 이하의 완전수는 4개 밖에 존재하지 않는다.
이 것이 바로 선진 코딩
perfect_num = {6 : "6 = 1 + 2 + 3",
28 : "28 = 1 + 2 + 4 + 7 + 14",
496: "496 = 1 + 2 + 4 + 8 + 16 + 31 + 62 + 124 + 248",
8128 : "8128 = 1 + 2 + 4 + 8 + 16 + 32 + 64 + 127 + 254 + 508 + 1016 + 2032 + 4064"}
num = int(input())
while num != -1:
if num in perfect_num:
print(perfect_num[num])
else:
print("%s is NOT perfect." % (num))
num = int(input())
'Programming [Python] > 백준 알고리즘 솔루션' 카테고리의 다른 글
#191 백준 파이썬 [10870] 피보나치 수 5 (0) | 2019.11.06 |
---|---|
#190 백준 파이썬 [11557] Yangjojang of The Year (0) | 2019.11.06 |
#188 백준 파이썬 [10214] Baseball - 고연전 (0) | 2019.11.05 |
#187 백준 파이썬 [10103] 주사위 게임 (0) | 2019.11.05 |
#186 백준 파이썬 [10162] 전자레인지 (0) | 2019.11.05 |