AtCoder Beginner Contest 139 - Power Socket

Takahashi's house has only one socket.
Takahashi wants to extend it with some number of power strips, each with A sockets, into B or more empty sockets.
One power strip with A sockets can extend one empty socket into A empty sockets.
Find the minimum number of power strips required.

-----Constraints-----
 - All values in input are integers.
 - 2 \leq A \leq 20
 - 1 \leq B \leq 20

-----Input-----
Input is given from Standard Input in the following format:
A B

-----Output-----
Print the minimum number of power strips required.

-----Sample Input-----
4 10

-----Sample Output-----
3

3 power strips, each with 4 sockets, extend the socket into 10 empty sockets.

Source: atcoder | Difficulty: EASY


Solutions:
import math
(A, B) = list(map(int, input().split()))
print(math.ceil((B - 1) / (A - 1)))


(a, b) = list(map(int, input().split()))
for i in range(1, 21):
	if b == 1:
		i = 0
		break
	x = a * i
	x = x - i + 1
	if x >= b:
		break
print(i)


(a, b) = map(int, input().split())
print(-((-b + 1) // (a - 1)))


(a, b) = map(int, input().split())
ans = (b + a - 3) // (a - 1)
print(ans)


(a, b) = map(int, input().split())
c = 1
t = 0
while c < b:
	c += a - 1
	t += 1
print(t)


(a, b) = map(int, input().split())
print(0 - -~-b // ~-a)


i = input()
print(0 - -~-int(i[2:]) // ~-int(i[:2]))


import math
(a, b) = map(int, input().split())
b -= 1
print(math.ceil(b / (a - 1)))


(A, B) = map(int, input().split())
print((B - 1) // (A - 1) + ((B - 1) % (A - 1) != 0))


(a, b) = map(int, input().split())
c = 1
cnt = 0
while c < b:
	c += a - 1
	cnt += 1
print(cnt)


(a, b) = list(map(int, input().split()))
if b == 1:
	print(0)
	return
for i in range(1, 1000):
	if b <= a * i - (i - 1):
		print(i)
		return


(A, B) = map(int, input().split())
N = 0
while 1 + (A - 1) * N < B:
	N += 1
print(N)


(a, b) = map(int, input().split())
k = 0
while (a - 1) * k + 1 < b:
	k += 1
print(k)


(A, B) = map(int, input().split())
print((B - 2) // (A - 1) + 1)


(a, b) = [int(x) for x in input().split()]
print((b - 1 + (a - 1) - 1) // (a - 1))


import math
(A, B) = map(int, input().split())
k = math.ceil((B - 1) / (A - 1))
print(k)


(a, b) = map(int, input().split())
for i in range(25):
	if b <= a + (a - 1) * (i - 1):
		print(i)
		break


(A, B) = map(int, input().split())
A = A - 1
B = B - 1
ans = (B + A - 1) // A
print(ans)


(a, b) = list(map(int, input().split()))
ans = 0
k = 1
while k < b:
	k -= 1
	k += a
	ans += 1
print(ans)


(A, B) = map(int, input().split())
socket = 1
taps = 0
while True:
	if socket >= B:
		break
	else:
		taps += 1
		socket = socket + (A - 1)
print(taps)


(A, B) = map(int, input().split())
n = 0
while A * n - n + 1 < B:
	n += 1
print(n)


(a, b) = map(int, input().split())
cnt = 0
tap = 1
while tap < b:
	tap = tap + (a - 1)
	cnt = cnt + 1
print(cnt)


(a, b) = map(int, input().split())
x = 0
c = 1
while c < b:
	c += a - 1
	x += 1
print(x)


import math
(x, y) = map(int, input().split())
print(math.ceil((y - 1) / (x - 1)))


(A, B) = map(int, input().split())
x = 0
while (A - 1) * x + 1 < B:
	x += 1
print(x)


from math import ceil
(A, B) = map(int, input().split())
print(ceil((B - A) / (A - 1)) + 1)


(A, B) = map(int, input().split())
cnt = 1
total = A
if B == 1:
	print(0)
else:
	while total < B:
		total += A - 1
		cnt += 1
	print(cnt)


(A, B) = map(int, input().split())
x = -(-(B - 1) // (A - 1))
print(x)


(a, b) = map(int, input().split())
n = 0
m = 1
while b > m:
	m += a - 1
	n += 1
print(n)


(a, b) = [int(x) for x in input().split()]
print(int((b - 1) / (a - 1) + 0.9999))


(a, b) = map(int, input().split())
a -= 1
use = 0
while 1 + a * use < b:
	use += 1
print(use)


(A, B) = map(int, input().split())
if B == 1:
	print(0)
elif A >= B:
	print(1)
else:
	for i in range(1, B):
		if B <= 1 + (A - 1) * i:
			print(i)
			return


(a, b) = map(int, input().split())
tmp = 1
ans = 0
while True:
	if tmp >= b:
		break
	tmp -= 1
	tmp += a
	ans += 1
print(ans)


(a, b) = map(int, input().split())
num = 1
c = 0
while num < b:
	num += a - 1
	c += 1
print(c)


(A, B) = map(int, input().split())
cnt = 1
ans = 0
while cnt < B:
	cnt += A - 1
	ans += 1
print(ans)


(A, B) = map(int, input().split())
i = 0
while 1 + (A - 1) * i < B:
	i += 1
print(i)


A_B = input().split()
print(-(-(int(A_B[1]) - 1) // (int(A_B[0]) - 1)))


(a, b) = map(int, input().split())
tap = 0
outlet = 1
while outlet < b:
	outlet -= 1
	outlet += a
	tap += 1
print(tap)


(A, B) = map(int, input().split())
import math
ans = math.ceil((B - A) / (A - 1)) + 1
print(ans)


(A, B) = map(int, input().split())
k = -(-(B - 1) // (A - 1))
print(k)


(a, b) = map(int, input().split())
c = 1
i = 0
while c < b:
	c = c - 1 + a
	i += 1
print(i)


(a, b) = map(int, input().split())
g = a - 1
(d, r) = divmod(b - 1, g)
if r == 0:
	print(d)
else:
	print(d + 1)


(a, b) = map(int, input().split())
n = 0
t = 1
while t < b:
	n += 1
	t += a - 1
print(n)


import math
(A, B) = map(int, input().split())
if B == 1:
	N = 0
elif A < B:
	N = math.ceil((B - A) / (A - 1)) + 1
else:
	N = 1
print(N)


from math import ceil

def answer(a: int, b: int) -> int:
	return ceil((b - 1) / (a - 1))

def main():
	(a, b) = list(map(int, input().split()))
	print(answer(a, b))

def __starting_point():
	main()
__starting_point()


(A, B) = [int(n) for n in input().split()]
print(1 + (B - 2) // (A - 1))


(a, b) = map(int, input().split())
s = a - 1
t = b - 1
print((s + t - 1) // s)


(A, B) = map(int, input().split())
print((B + A - 3) // (A - 1))


i = input()
print(-(~-int(i[2:]) // -~-int(i[:2])))


(a, b) = list(map(int, input().split()))
plug = 1
cnt = 0
while plug < b:
	plug = plug + a - 1
	cnt += 1
print(cnt)


import sys
(A, B) = map(int, sys.stdin.readline().split())
print((B - A - 1) // (A - 1) + 2)


(a, b) = map(int, input().split())
ans = (b - 1 + (a - 2)) // (a - 1)
print(ans)


(a, b) = list(map(int, input().split()))
print((b - 2) // (a - 1) + 1)


import math
(a, b) = list(map(int, input().split()))
ans = math.ceil((b - 1) / (a - 1))
print(ans)


(A, B) = [int(x) for x in input().split()]
ans = -(-(B - 1) // (A - 1))
print(ans)


(a, b) = map(int, input().split())
ans = 0
out = 1
while out < b:
	out -= 1
	out += a
	ans += 1
print(ans)


(a, b) = map(int, input().split())
ans = 0
outlet = 1
while outlet < b:
	outlet -= 1
	outlet += a
	ans += 1
print(ans)


import math
(A, B) = map(int, input().split())
print((B + A - 3) // (A - 1))


import math
(A, B) = map(int, input().split())
N = math.ceil((B - A) / (A - 1) + 1)
print(N)


(a, b) = map(int, input().split())
con = 1
ans = 0
while con < b:
	con += a - 1
	ans += 1
print(ans)


(A, B) = map(int, input().split())
K = 0
M = 1
while M < B:
	K += 1
	M += A - 1
print(K)


(a, b) = map(int, input().split())
c = b - a
if c % (a - 1) == 0:
	n = c // (a - 1) + 1
else:
	n = c // (a - 1) + 2
print(n)


(A, B) = input().split()
a = int(A)
b = int(B)
for i in range(b):
	if 1 + a * i - i >= b:
		print(i)
		break


(A, B) = map(int, input().split())
N = -(-(B - A) // (A - 1)) + 1
print(N)


(A, B) = map(int, input().split())
if B == 1:
	print(0)
elif A >= B:
	print(1)
else:
	count = 0
	for n in range(1, 100):
		if A + (A - 1) * n >= B:
			print(n + 1)
			break


(a, b) = map(int, input().split())
c = 1
d = 0
while c < b:
	d += 1
	c += a - 1
print(d)


(A, B) = (int(x) for x in input().split())
i = 0
while i * (A - 1) < B - 1:
	i += 1
print(i)


(a, b) = [int(_) for _ in input().split()]
print((b + a - 3) // (a - 1))


(A, B) = [int(hoge) for hoge in input().split()]
print((B - 2) // (A - 1) + 1)


def resolve():
	(a, b) = map(int, input().split())
	cnt = 1
	ans = 0
	while cnt < b:
		cnt = cnt - 1 + a
		ans += 1
	print(ans)
resolve()


(a, b) = input().split()
print(abs(-(int(b) - 1) // (int(a) - 1)))


(a, b) = map(int, input().split())
c = 1
count = 0
while c < b:
	c += a - 1
	count += 1
print(count)


(a, b) = map(int, input().split())
cnt = 1
plg = 0
while cnt < b:
	cnt -= 1
	cnt += a
	plg += 1
print(plg)


(a, b) = [int(i) for i in input().split()]
ans = (b - 1) // (a - 1) + 1 if (b - 1) % (a - 1) else (b - 1) // (a - 1)
print(ans)


(a, b) = input().strip().split(' ')
(a, b) = [int(a), int(b)]
print((a + b - 3) // (a - 1))


(A, B) = map(int, input().split())
a = 0
num = 1
while num < B:
	num -= 1
	num += A
	a += 1
print(a)


(a, b) = map(int, input().split())
x = 1
ans = 0
while x < b:
	x += a - 1
	ans += 1
print(ans)


(A, B) = map(int, input().split())
s = 0
while B - (A - 1) * s - 1 > 0:
	s += 1
print(s)


(a, b) = map(int, input().split())
c = 1
ans = 0
while c < b:
	ans += 1
	c += a - 1
print(ans)


(a, b) = list(map(int, input().split()))
i = 0
while b > (a - 1) * i + 1:
	i += 1
print(i)


from sys import stdin
nii = lambda : map(int, stdin.readline().split())
lnii = lambda : list(map(int, stdin.readline().split()))
(a, b) = nii()
num = 1
ans = 0
while num < b:
	ans += 1
	num += a - 1
print(ans)


(A, B) = map(int, input().split())
outlet = 1
cnt = 0
while outlet < B:
	outlet += A - 1
	cnt += 1
print(cnt)


(a, b) = map(int, input().split())
print((b - 1) // (a - 1) + (1 if (b - 1) % (a - 1) != 0 else 0))


(A, B) = map(int, input().split())
c = 0
while A * c - c + 1 < B:
	c += 1
print(c)


(a, b) = map(int, input().strip().split())
print(max(0, (b - 2) // (a - 1) + 1))


(a, b) = [int(x) for x in input().split()]
res = 0
c = 1
while c < b:
	c += a - 1
	res += 1
print(res)


(A, B) = map(int, input().split())
if (B - 1) % (A - 1) == 0:
	print((B - 1) // (A - 1))
else:
	print((B - 1) // (A - 1) + 1)


(a, b) = map(int, input().split())
ans = 1
i = 0
if b != 1:
	while ans < b:
		i += 1
		ans = a + (a - 1) * (i - 1)
print(i)


(A, B) = map(int, input().split())
answer = 1
plug = A
if B == 1:
	print(0)
	return
while B > A:
	answer += 1
	A += plug - 1
print(answer)


(A, B) = input().split()
import math
print(math.ceil((int(B) - 1) / (int(A) - 1)))


(a, b) = map(int, input().split())
aki = 1
ans = 0
while aki < b:
	aki += a - 1
	ans += 1
print(ans)


(A, B) = map(int, input().split())
num = 1
ans = 0
while True:
	if num >= B:
		break
	ans += 1
	num += A - 1
print(ans)


(a, b) = map(int, input().split())
ans = 1
count = 0
while ans < b:
	count += 1
	ans += a - 1
print(count)


import math
(A, B) = list(map(int, input().split()))
ans = math.ceil((B - 1) / (A - 1))
if B <= 1:
	print(0)
else:
	print(ans)


(x, y) = map(int, input().split())
print(-(-(y - 1) // (x - 1)))


(x, y) = map(int, input().split())
ans = 1
total = x
while total < y:
	ans += 1
	total += x
	total -= 1
print(ans if y != 1 else 0)


(a, b) = [int(i) for i in input().split()]
print(-((1 - b) // (a - 1)))


(A, B) = map(int, input().split())
num = 1
for i in range(20):
	if i != 0:
		num += A - 1
	if num >= B:
		print(i)
		break


import math as mt
(a, b) = map(int, input().split())
n = 1
while a + (a - 1) * (n - 1) < b:
	n += 1
print(n if b != 1 else 0)


(a, b) = map(int, input().split())
c = a - 1
d = b - 1
print(d // c + 1 if d % c != 0 else d // c)


(N, H) = map(int, input().split())
import math
print(math.ceil((H - 1) / (N - 1)))


(A, B) = map(int, input().split())
a = 0
t = 1
while t < B:
	t += A - 1
	a += 1
print(a)


(a, b) = map(int, input().split())
free = 1
ans = 0
while free < b:
	free += a - 1
	ans += 1
print(ans)


a = list(map(int, input().split()))
print(-(-(a[1] - 1) // (a[0] - 1)))


(A, B) = map(int, input().split(' '))
outlet = 1
tap = 0
while outlet < B:
	outlet = outlet - 1 + A
	tap = tap + 1
	if outlet >= B:
		break
print(tap)


(a, b) = map(int, input().split())
ans = 0 - -(b - 1) // (a - 1)
print(ans)


import math
(a, b) = map(float, input().split())
print(math.ceil((b - 1) / (a - 1)))


(A, B) = map(int, input().split())
r = (B - 1 + A - 1 - 1) // (A - 1)
print(r)


(a, b) = map(int, input().split())
x = 0
for i in range(b):
	if x >= b:
		break
	elif i == 0:
		x += a
	else:
		x += a - 1
print(i)


(a, b) = list(map(int, input().split()))
print((b + a - 3) // (a - 1))


(a, b) = map(int, input().split())
result = (b - 2) // (a - 1) + 1
print(result)


(A, B) = map(int, input().split())
AA = A - 1
BB = B - 1
print((BB + AA - 1) // AA)


(A, B) = map(int, input().split())
p = 1
ans = 0
while p < B:
	p += A - 1
	ans += 1
print(ans)


(a, b) = (int(x) for x in input().split())
ans = 0
count = 1
while count < b:
	count += a - 1
	ans += 1
print(ans, '\n')


(a, b) = map(int, input().split())
t = a
count = 1
if b != 1:
	while t < b:
		t += a - 1
		count += 1
	print(count)
else:
	print(0)


(A, B) = map(int, input().split())
q = -((-B + 1) // (A - 1))
print(q)


(a, b) = map(int, input().split())
(d, m) = divmod(b - 1, a - 1)
print(d + bool(m))


import math
(a, b) = map(int, input().split())
c = a - 1
d = b - 1
print(math.ceil(d / c))


(a, b) = map(int, input().split())
ans = 1
c = b - a
ans += (c - 1) // (a - 1) + 1
print(ans)


(a, b) = map(int, input().split())
c = (b - 2) // (a - 1) + 1
print(c)


(t, h) = map(int, input().split())
print((h - 2) // (t - 1) + 1)


(a, b) = map(int, input().split())
B = b - 1
A = a - 1
ans = (B + A - 1) // A
print(ans)


(a, b) = map(int, input().split())
ans = 0
tap = 1
while tap < b:
	tap += a - 1
	ans += 1
print(ans)


(a, b) = map(lambda x: int(x) - 1, input().split())
print((b + a - 1) // a)


(A, B) = map(int, input().split())
ans = max(0, (B + A - 3) // (A - 1))
print(ans)


(A, B) = (int(a) for a in input().split())
print(-(-(B - 1) // (A - 1)))


import math
(a, b) = [int(n) for n in input().split()]
print(math.ceil((b - 1) / (a - 1)))


(A, B) = [int(_) for _ in input().split()]
print((B - 1 + A - 2) // (A - 1))


(A, B) = map(int, input().split())
print(-round(-(B - 1) // (A - 1)))


m = list(map(int, input().split()))
print(-(-(m[1] - 1) // (m[0] - 1)))


(A, B) = map(int, input().split())
ans = 0
res = 1
while res < B:
	res += A - 1
	ans += 1
print(ans)


(A, B) = map(int, input().split())
count = 1
ans = 0
if B == 1:
	print(0)
	return
for i in range(100):
	ans += 1
	count += A - 1
	if count >= B:
		break
print(ans)


(a, b) = map(int, input().split())
if b == 1:
	print(0)
else:
	for i in range(1, 100):
		ans = 1 + i * (a - 1)
		if ans >= b:
			print(i)
			break


import math
(a, b) = map(int, input().split())
A = a - 1
B = b - 1
print(math.ceil(B / A))


(A, B) = list(map(int, input().split()))
print(-(-(B - 1) // (A - 1)))


(N, K) = map(int, input().split())
c = N
ans = 1
if K == 1:
	print(0)
else:
	while c < K:
		ans += 1
		c += N - 1
	print(ans)


(A, B) = list(map(int, input().split()))
N = 0
sum = 1
while sum < B:
	N += 1
	sum = A + (A - 1) * (N - 1)
	if sum >= B:
		break
ans = N
print(ans)