[TIL] BOJ [2839]설탕 배달, [2231]분해합

Updated:

[2839] 설탕 배달

image

N = int(input())

bag = 0

while N >= 0:

    if N % 5 == 0:

        bag += (N // 5)

        N -= 5

        print(bag)

        break

    N -= 3

    bag += 1


else:

    print(-1)


[2231] 분해합

image

N = int(input())

result = 0

for i in range(1, N+1):

    A = list(map(int, str(i)))

    result = i + sum(A)

    if result == N :

        print(i)

        break

    if i==N:

        print(0)