본문 바로가기
Algorithm/Greedy

[백준] 2231번 분해합

by 등촌동 꼬북이 2021. 2. 4.

쉬운 문제

 

val = int(input())
ans = 0

for i in range(1, val +1):
    tempList = list(map(int, str(i)))
    ans = i + sum(tempList)
    if ans == val:
        print(i)
        break
    if i == val:
        print(0)
        break

'Algorithm > Greedy' 카테고리의 다른 글

[백준] 1541번 잃어버린 괄호  (0) 2021.01.24
[백준] 1339번 단어수학  (0) 2021.01.23
[백준] 11501번 주식  (0) 2021.01.14
[백준] 2812번 크게 만들기  (0) 2020.11.28
[백준] 11508번 2+1 세일  (0) 2020.10.20

댓글