BOJ - 4564 - 숫자 카드놀이

Updated:

import sys

def solution():

    while True:
        S = int(sys.stdin.readline())
        if not S:
            break

        ret = [str(S)]
        while S >= 10:
            tempS = 1
            for i in range(len(str(S))):
                tempS *= int(str(S)[i])

            ret.append(str(tempS))
            S = tempS
        print((' ').join(ret))
solution()

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

Categories:

Updated:

Leave a comment