코딩테스트/이코테 2021

코딩테스트/이코테 2021

[이코테2021] 1이 될 때까지 - Python

#N을 K로 나누거나 N에 -1을 할 때 #N이 1이 될 때까지의 COUNT를 구하여 출력한다 import sys input=sys.stdin.readline n,k = map(int,input().split()) cnt = 0 while True: if n == 1: break if n%k == 0: cnt+=1 n //= k else: cnt+=1 n -= 1 print(cnt)

PgmJUN
'코딩테스트/이코테 2021' 카테고리의 글 목록 (2 Page)