๐ก
while (True):
N = int(input())
cnt = [] #์ฝ์ ๋ฆฌ์คํธ์ ๋ด๊ธฐ
sum = 0
if N == -1:
break
cnt.append(N)
for i in range(1,N+1):
if ( N % i == 0):
cnt.append(i)
sum += i
if ( (sum-N) != N ) :
print(cnt[0],end='')
print(" is NOT perfect.")
elif ( (sum-N) == N ) :
print(cnt[0],end='')
print(" =", cnt[1],end='')
for i in range(2,len(cnt)-1):
print(" + " ,end='')
print(cnt[i] ,end='')
print()
[์คํจ] ๋ถ๋ช ์ ๋ต์ ๋ง๋๋ฐ ์์ด๋ฌ์ง ์ถ์๋๋ฐ
์ ๋ ฅ๊ฐ์ ํ์ค์ฉ ๋ฐ๊ณ ๋๋ด๋ ์ค ์์๋๋ฐ ์ฐ์์ผ๋ก ๋ฐ๋ ๊ฑฐ์๋ค.
๊ทธ๋ถ๋ถ๋ง ๊ณ ์ณ์ฃผ๋ ๋ฐ๋ก ํต๊ณผ !
N = int(input())
cnt = [] #์ฝ์ ๋ฆฌ์คํธ์ ๋ด๊ธฐ
sum = 0
cnt.append(N)
for i in range(1,N+1):
if ( N % i == 0):
cnt.append(i)
sum += i
if (sum < 0):
pass
elif ( (sum-N) != N and sum > 0) :
print(cnt[0],end='')
print(" is NOT perfect.")
elif ( (sum-N) == N and sum > 0) :
print(cnt[0],end='')
print(" =", cnt[1],end='')
for i in range(2,len(cnt)-1):
print(" + " ,end='')
if (i == len(cnt)+1):
print(cnt[len(cnt)+1])
print(cnt[i] ,end='')