Skip to content

Baekjoon 2331

1. Problem

문제 확인하기

2. Solution

A, P = map(int, input().split())
lst = [A]
while True:
    tmp = 0
    for i in str(lst[-1]):
        tmp += int(i) ** P
    if tmp in lst:
        break
    lst.append(tmp)
print(lst.index(tmp))