AtCoder Beginner Contest 156 - Digits

Given is an integer N. Find the number of digits that N has in base K.

-----Notes-----
For information on base-K representation, see Positional notation - Wikipedia.

-----Constraints-----
 - All values in input are integers.
 - 1 \leq N \leq 10^9
 - 2 \leq K \leq 10

-----Input-----
Input is given from Standard Input in the following format:
N K

-----Output-----
Print the number of digits that N has in base K.

-----Sample Input-----
11 2

-----Sample Output-----
4

In binary, 11 is represented as 1011.

Difficulty: EASY

Starter code:

Solutions:
(N, K) = map(int, input().split())
(q, mod) = divmod(N, K)
mod_list = [mod]
while True:
	(q, mod) = divmod(q, K)
	mod_list.append(mod)
	if q <= 0:
		break
if mod_list[-1] == 0:
	result = len(mod_list) - 1
else:
	result = len(mod_list)
print(result)


(N, K) = map(int, input().split())
for i in range(10 ** 9):
	if N < K ** i:
		print(i)
		break


(a, b) = map(int, input().split())
cnt = 0
while a > 0:
	a //= b
	cnt += 1
print(cnt)


(n, k) = map(int, input().split())

def max_beki(number, k):
	beki = 0
	while k ** beki <= number:
		beki += 1
	return beki
res = []
waru_kazu = k ** (max_beki(n, k) - 1)
while waru_kazu >= 1:
	shou = n // waru_kazu
	res.append(str(shou))
	n -= shou * waru_kazu
	waru_kazu /= k
print(len(res))


(n, k) = list(map(int, input().split()))
i = 0
a = []
while n != 0:
	a.append(n % k)
	n = n // k
	i = i + 1
print(len(a))


(N, K) = list(map(int, input().split()))
i = 1
while N // K >= 1:
	N = N // K
	i += 1
print(i)


def resolve():
	(n, k) = map(int, input().split())
	ans = 0
	while n != 0:
		n = n // k
		ans += 1
	print(ans)
resolve()


(N, K) = map(int, input().split())
count = 0
while N >= 1:
	ans = N // K
	N = ans
	count += 1
print(count)


import math
(N, K) = list(map(int, input().split()))
print(int(math.log(N, K)) + 1)


(n, k) = (int(x) for x in input().split())
i = 0
while n >= k ** i:
	i += 1
print(i)


(n, k) = map(int, input().split())
a = 0
while n:
	n //= k
	a += 1
print(a)


(N, K) = map(int, input().split())
i = 0
anslist = []
while True:
	if N >= K:
		i += 1
		anslist.append(N % K)
		N = N // K
	if N < K:
		anslist.append(N)
		i += 1
		break
anslist.reverse()
print(i)


(N, K) = map(int, input().split())
i = 0
while N > 0:
	N = N // K
	i += 1
print(i)


(n, k) = map(int, input().split())
cnt = 0
while n:
	cnt += 1
	n //= k
print(cnt)


(N, K) = map(int, input().split())
x = 0
while N >= 1:
	x += 1
	N = N // K
print(x)


(n, k) = map(int, input().split())
x = 1
while n // k > 0:
	n = n // k
	x += 1
print(x)


(n, k) = list(map(int, input().split()))
answer = n // k
count = 1
while 0 < answer:
	answer = answer // k
	count += 1
print(count)


(N, K) = map(int, input().split())
cnt = 1
while N >= K:
	cnt += 1
	N = N // K
print(cnt)


(n, k) = map(int, input().split())
num = k
ans = 1
while num - 1 < n:
	ans += 1
	num *= k
print(ans)


from math import log
(n, k) = map(int, input().split())
print(int(log(n, k) + 1))


(n, k) = map(int, input().split())
i = 0
while n >= k ** i:
	i += 1
print(i)


(N, M) = map(int, input().split())
c = 0
while N != 0:
	c += 1
	N //= M
print(c)


(N, K) = map(int, input().split())
count = 0
while True:
	if N >= pow(K, count):
		count += 1
	else:
		break
print(count)


(K, N) = map(int, input().split())
t = 0
while K != 0:
	K = K // N
	t = t + 1
print(t)


import math
(n, k) = map(int, input().split())
x = int(math.log(n) // math.log(k)) + 1
print(x)


(n, k) = list(map(int, input().split()))
i = 0
while True:
	if k ** i > n:
		print(i)
		break
	i += 1


(n, k) = map(int, input().split())
ans = 1
n1 = n
while n1 // k >= 1:
	n1 = n1 // k
	ans += 1
print(ans)


(N, K) = map(int, input().split())
s = 0
while N >= K ** s:
	s = s + 1
print(s)


import math
(n, k) = map(int, input().split())
print(math.floor(math.log(n, k) + 1))


(N, K) = map(int, input().split())
rank = 1
S = K
while N >= S:
	rank += 1
	S *= K
print(rank)


def Ten_to_n(X, n):
	if int(X / n):
		return Ten_to_n(int(X / n), n) + str(X % n)
	return str(X % n)
(n, k) = list(map(int, input().split()))
print(len(Ten_to_n(n, k)))


(N, K) = map(int, input().split())
c = 0
while N > 0:
	N //= K
	c += 1
print(c)


import math
(n, k) = (int(x) for x in input().split())
print(int(math.log(n, k)) + 1)


(N, K) = map(int, input().split())
ans = 1
while N >= K:
	N = N // K
	ans += 1
print(ans)


(N, K) = map(int, input().split())
(p, c) = (1, 1)
while p <= N:
	p *= K
	c += 1
print(c - 1)


(N, K) = list(map(int, input().split()))
answer = 1
if K == 10:
	Str = str(N)
	answer = len(Str)
	print(answer)
	return
while N // K > 0:
	N = N // K
	answer += 1
print(answer)


(N, K) = map(int, input().split())
keta = 1
while N >= K:
	keta += 1
	N = N / K
print(keta)


import math

def findNumberOfDigits(n, b):
	dig = math.floor(math.log(n) / math.log(b)) + 1
	return dig
(n, k) = map(int, input().strip().split())
print(findNumberOfDigits(n, k))


(n, k) = map(int, input().split())
for a in range(10 ** 9):
	if k ** a > n:
		print(a)
		break


i = list(map(int, input().split()))
j = 1
while i[0] >= i[1] ** j:
	j += 1
print(j)


def readinput():
	(n, k) = list(map(int, input().split()))
	return (n, k)

def main(n, k):
	keta = 0
	while n > 0:
		keta += 1
		r = n % k
		n = n // k
	return keta

def __starting_point():
	(n, k) = readinput()
	ans = main(n, k)
	print(ans)
__starting_point()


(N, K) = map(int, input().split())
D = []
while N > 0:
	D.append(N % K)
	N = N // K
print(len(D))


(n, k) = list(map(int, input().split()))
import math
print(int(math.log(n, k) + 1))


(n, k) = list(map(int, input().split()))
a = 1
while n >= k ** a:
	a += 1
print(a)


(n, m) = map(int, input().split())
ans = 0
c = 1
while c <= n:
	c *= m
	ans += 1
print(ans)


(N, K) = map(int, input().split())
n = N
i = 1
while 1 > 0:
	n = n // K
	if n == 0:
		print(i)
		break
	i += 1


(n, k) = map(int, input().split())
r = 0
while k ** r <= n:
	r += 1
print(r)


(n, k) = map(int, input().split())
ans = 0
while n > 0:
	n = n // k
	ans += 1
print(ans)


(n, k) = map(int, input().split())
num = 0
while n > 0:
	n //= k
	num += 1
print(num)


(n, k) = map(int, input().split())
c = 1
while n >= k:
	n //= k
	c += 1
print(c)


(N, K) = map(int, input().split())
n = 0
while not K ** n > N:
	n += 1
print(n)


(n, k) = map(int, input().split())
print(sum((n >= k ** i for i in range(100))))


def main():
	(t, n) = list(map(int, input().split()))
	binary = 0
	ctr = 0
	temp = t
	while temp > 0:
		binary = temp % n * 10 ** ctr + binary
		temp = int(temp / n)
		ctr += 1
	return len(str(binary))

def __starting_point():
	print(main())
__starting_point()


(N, K) = map(int, input().split())
A = 0
while N >= K ** A:
	A = A + 1
print(A)


(n, k) = map(int, input().split())
lists = []
ans = 0
while True:
	if n < k:
		ans += 1
		break
	(n, b) = divmod(n, k)
	ans += 1
print(ans)


import queue
(N, K) = map(int, input().split())
ans = queue.Queue()
while N >= K:
	(N, amari) = divmod(N, K)
	ans.put(amari)
ans.put(N)
answer = ''
while not ans.empty():
	answer += str(ans.get())
print(len(answer))


(a, b) = map(int, input().split())
c = 0
while a != 0:
	a = int(a / b)
	c += 1
print(c)


(n, k) = map(int, input().split())
total = []
while True:
	if n >= k:
		total.append(n % k)
		n = n // k
	if n < k:
		total.append(n)
		break
print(len(total))


(n, r) = map(int, input().split())
b = 1
while n // r != 0:
	n //= r
	b += 1
print(b)


(n, k) = map(int, input().split())
counter = 0
while n >= k:
	n = n // k
	counter = counter + 1
print(counter + 1)


(n, k) = map(int, input().split())
keta = 1
while k ** keta <= n:
	keta += 1
print(keta)


(N, K) = map(int, input().split())
C = 0
while N > 0:
	N = N // K
	C += 1
print(C)


(n, m) = map(int, input().split())
import math
print(int(math.log(n, m) // 1) + 1)


(N, K) = map(int, input().split())

def ans156(N: int, K: int):
	length = 1
	while True:
		if N < K:
			break
		N = int(N / K)
		length += 1
	return length
print(ans156(N, K))


(N, K) = map(int, input().split())
n = 1
while True:
	if K ** (n - 1) <= N < K ** n:
		break
	n += 1
print(n)
return


(n, k) = map(int, input().split())
a = 1
b = k
while n >= b:
	b = b * k
	a += 1
print(a)


n = list(map(int, input().split()))
C = 0
while n[0] >= n[1] ** C:
	C += 1
print(C)


(n, k) = map(int, input().split())
s = 0
while n > k - 1:
	n = n // k
	s += 1
print(s + 1)


(N, K) = map(int, input().split())
r = 0
while N:
	N //= K
	r += 1
print(r)


(n, k) = map(int, input().split())
ans = []
while n > 0:
	ans.append(n % k)
	n /= k
	n = int(n)
print(len(ans))


(N, K) = map(int, input().split())
count = 1
while N >= K:
	N = N // K
	count += 1
print(count)


(N, K) = map(int, input().split())
a = 0
while N > 0:
	a += 1
	N = N // K
print(a)


(a, b) = map(int, input().split())
ans = 0
while a > 0:
	a = a // b
	ans += 1
print(ans)


(N, K) = map(int, input().split())
ans_str = ''
n = N
while n >= K:
	n = n // K
	ans_str += str(n % K)
ans_str += str(n)
print(len(ans_str))


(n, k) = map(int, input().split())
for i in range(100):
	if k ** i <= n and n <= k ** (i + 1) - 1:
		print(i + 1)
		break


(N, K) = map(int, input().split())
digit = 0
while N > 0:
	N = N // K
	digit += 1
print(digit)


(n, k) = map(int, input().split())
s = str()
while n > 0:
	n = n // k
	s += '1'
print(len(s))


def main():
	(N, K) = map(int, input().split())
	if N < K:
		print(1)
		return
	cnt = 0
	while N > 0:
		N = N // K
		cnt += 1
	print(cnt)
main()


(n, k) = map(int, input().split())
ct = 0
while n > 0:
	ct += 1
	n //= k
print(ct)


import os, sys, re, math
(N, K) = [int(n) for n in input().split()]
d = 0
a = K ** 0
while a <= N:
	d += 1
	a *= K
print(d)


(N, K) = map(int, input().split())
m = 0
while K ** m <= N:
	m += 1
print(m)


(N, K) = map(int, input().split())
d = 0
while K ** d <= N:
	d += 1
print(d)


import math
(n, k) = map(int, input().split())
a = math.log(n, k)
print(int(a) + 1)


from math import log
(N, K) = map(int, input().split())
print(int(log(N, K)) + 1)


import math
(N, K) = map(int, input().split())
A = math.log(N, K)
print(int(A) + 1)


import math
(a, b) = map(int, input().split())
print(int(math.log(a, b)) + 1)


import math
(N, K) = map(int, input().split())
print(math.floor(math.log(N, K)) + 1)


c = 0
(n, b) = map(int, input().split())
while n > 0:
	c += 1
	n //= b
print(c)


(n, k) = map(int, input().split())
lists = []
while True:
	if n < k:
		lists.append(n)
		break
	(n, b) = divmod(n, k)
	lists.append(b)
ans_list = reversed(lists)
print(len(''.join(map(str, ans_list))))


(N, K) = list(map(int, input().split()))
cnt = 0
while N > 0:
	cnt += 1
	N //= K
print(cnt)


(integer, base) = map(int, input().split())
converted_number = ''
while integer > 0:
	converted_number += str(integer % base)
	integer //= base
print(len(converted_number[::-1]))


(n, k) = map(int, input().split())
l = 1
while n > k - 1:
	n = n // k
	l += 1
print(l)


def answer(n: int, k: int) -> int:
	digits = 0
	while 0 < n:
		n //= k
		digits += 1
	return digits

def main():
	(n, k) = map(int, input().split())
	print(answer(n, k))

def __starting_point():
	main()
__starting_point()


def L():
	return list(map(int, input().split()))
import math
[n, k] = L()
print(math.floor(math.log(n, k)) + 1)


(N, K) = list(map(int, input().split()))
ans = 0
while N >= K:
	N = N // K
	ans += 1
print(ans + 1)


import math
(N, K) = map(int, input().split())
C = math.log(N, K)
print(int(C) + 1)


nk = list(map(int, input().split()))
(n, k) = (nk[0], nk[1])
digit = 0
while n > k ** digit - 1:
	digit += 1
print(digit)


(N, K) = map(int, input().split())
p = 0
while K ** p <= N:
	p += 1
print(p)


(n, k) = map(int, input().split())
e = 1
while pow(k, e) <= n:
	e += 1
print(e)


(N, K) = list(map(int, input().split()))
ans = 0
while True:
	if not N - K ** ans >= 0:
		print(ans)
		break
	else:
		ans += 1


import math
(n, k) = map(int, input().split())
t = math.log(n, k)
print(int(t) + 1)


(n, k) = map(int, input().split())
j = 0
while k ** j <= n:
	j += 1
print(j)


(N, K) = map(int, input().split())
a = 0
i = 1
while pow(K, i) <= N:
	a += 1
	i += 1
print(a + 1)


(N, K) = map(int, input().split())
power = 1
while True:
	if N < K ** power:
		break
	else:
		power += 1
print(power)


n = input()
n = n.split()
k = int(n[1])
n = int(n[0])
a = 1
b = 0
while a == 1:
	b = b + 1
	if k ** b > n:
		a = 0
print(b)


(N, K) = map(int, input().split())
ans = 1
while N > 1:
	N = N // K
	ans += 1
if N % K == 0:
	ans -= 1
print(ans)


(n, k) = list(map(int, input().split()))
lists = []
ans = 0
while int(n) > 0:
	(n, b) = divmod(n, k)
	ans += 1
print(ans)


(N, K) = map(int, input().split())
b = 0
while N > 0:
	N = N // K
	b += 1
print(b)


(n, k) = map(int, input().split())
m = 1
while n >= k ** m:
	m += 1
print(m)


(n, k) = map(int, input().split())
t = 0
while n >= k ** t:
	t += 1
print(t)


(n, k) = map(int, input().split())
ans = 1
while True:
	n = n // k
	if n == 0:
		break
	ans += 1
print(ans)


(N, K) = map(int, input().split())
print(sum((N >= K ** i for i in range(99))))


(N, K) = list(map(int, input().split()))
ct = 0
while N > 0:
	N = N // K
	ct += 1
print(ct)


(n, k) = map(int, input().split())
c = 0
while n:
	(c, n) = (-~c, n // k)
print(c)


(n, k) = map(int, input().split())
count = 0
while n != 0:
	n = n // k
	count += 1
print(count)


(n, k) = map(int, input().split())
l = []
while n != 0:
	r = divmod(n, k)
	n = r[0]
	l.append(r[1])
print(len(l))


(x, k) = map(int, input().split())
ans = 0
while k ** ans <= x:
	ans += 1
print(ans)


(n, r) = map(int, input().split())
import math
print(int(math.log(n, r)) + 1)


(n, k) = list(map(int, input().split()))
for i in range(10 ** 9):
	if n < k ** i:
		print(i)
		break


import math
(N, K) = (int(x) for x in input().split())
print(int(math.log(N, K)) + 1)


from math import log
print(int(log(*map(int, input().split()))) + 1)


def Base_10_to_n(X, n):
	if int(X / n):
		return Base_10_to_n(int(X / n), n) + str(X % n)
	return str(X % n)
(N, K) = list(map(int, input().split()))
print(len(Base_10_to_n(N, K)))


(n, k) = map(int, input().split())
p = []
while n:
	p.append(n % k)
	n //= k
print(len(p))


(n, k) = map(float, input().split())
i = 0
while n >= 1:
	n = n / k
	i = i + 1
print(i)


(n, k) = map(int, input().split())
t = k
g = 1
while t - 1 < n:
	t = t * k
	g += 1
print(g)


def calc_digits(n: int, k: int) -> str:
	if int(n / k):
		return calc_digits(int(n / k), k) + str(n % k)
	return str(n % k)
(n, k) = list(map(int, input().split()))
print(len(calc_digits(n, k)))


(N, K) = map(int, input().split())
n = 1
while N >= K ** n:
	n += 1
print(n)


(n, k) = list(map(int, input().split()))
l = []
while n > 0:
	l.append(n % k)
	n //= k
print(len(l))


(N, K) = map(int, input().split())
result = 1
while N >= K:
	N = int(N / K)
	result += 1
print(result)


(n, d) = map(int, input().split())
a = 0
while n:
	n //= d
	a += 1
print(a)


(N, K) = map(int, input().split())
D = 0
while N:
	N //= K
	D += 1
print(D)


import math
(n, k) = map(int, input().split())
ans = 0
while n:
	n = int(n / k)
	ans += 1
print(ans)


(N, K) = map(int, input().split())
(q, mod) = divmod(N, K)
mod_list = [mod]
while True:
	(q, mod) = divmod(q, K)
	mod_list.append(mod)
	if q <= 0:
		break
n_ary = int(''.join(map(str, mod_list[::-1])))
print(len(str(n_ary)))


def base10toK_base(num, K):
	if num // K:
		return base10toK_base(num // K, K) + str(num % K)
	return str(num % K)
(N, K) = map(int, input().split())
ans = len(base10toK_base(N, K))
print(ans)


(n, k) = map(int, input().split())
p = 0
while n >= k ** p:
	p += 1
print(p)