[Algorithm/이코테] 그리디 - 1이 될 때까지

토시·2022년 5월 4일
0
# N, K = map(int, input().split())

N = 25
K = 3

cnt = 0
while N >= K:

  target = (N // K) * K
  cnt += N - target
  N = target
  N //= K
  cnt += 1

cnt += (N - 1)

print(cnt)
profile
개발하는 토시

0개의 댓글