본문 바로가기

Programming [Python]/백준 알고리즘 솔루션

#77 백준 파이썬 [2231] 분해합

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

 

#Solution

num = int(input())
answer = 0

for i in range(1, num+1):
    coef_num_list = list(map(int, str(i)))
    answer = i + sum(coef_num_list)
    
    if answer == num:
        print(i)
        break

    if i == num:
        print(0)