AtCoder Beginner Contest 076 - Addition and Multiplication

Square1001 has seen an electric bulletin board displaying the integer 1.
He can perform the following operations A and B to change this value:
 - Operation A: The displayed value is doubled.
 - Operation B: The displayed value increases by K.
Square1001 needs to perform these operations N times in total.
Find the minimum possible value displayed in the board after N operations.

-----Constraints-----
 - 1 \leq N, K \leq 10
 - All input values are integers.

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

-----Output-----
Print the minimum possible value displayed in the board after N operations.

-----Sample Input-----
4
3

-----Sample Output-----
10

The value will be minimized when the operations are performed in the following order: A, A, B, B.

In this case, the value will change as follows: 1 → 2 → 4 → 7 → 10.

Difficulty: EASY

Starter code:

Solutions:
a = 1
s = int(input())
d = int(input())
for i in range(s):
	a += min(a, d)
print(a)


n = int(input())
k = int(input())
i = 1
for _ in range(n):
	i = i + min(i, k)
print(i)


N = int(input())
K = int(input())
ans = 1
for _ in range(N):
	if ans + K < 2 * ans:
		ans += K
	else:
		ans *= 2
print(ans)


n = int(input())
k = int(input())
ans = 1
for i in range(n):
	ans = min(ans * 2, ans + k)
print(ans)


n = int(input())
k = int(input())
ans = 1
for _ in range(n):
	if ans < k:
		ans *= 2
	else:
		ans += k
print(ans)


(a, b) = (int(input()), int(input()))
ans = 1
for i in range(a):
	ans = min(ans * 2, ans + b)
print(ans)


(N, K) = [int(input()) for _ in range(2)]
c = 1
for i in range(N):
	if c < K:
		c *= 2
	else:
		c += K
print(c)


(N, K) = [int(input()) for i in range(2)]
p = 1
for i in range(N):
	p = min(2 * p, p + K)
print(p)


(n, k) = map(int, open(0))
p = 1
for _ in range(1, n + 1):
	p = [p + k, p * 2][p * 2 < p + k]
print(p)


n = int(input())
k = int(input())
j = 1
for i in range(n):
	j += min(j, k)
print(j)


(n, k) = eval('int(input()),' * 2)
r = 1
exec('r+=min(r,k);' * n)
print(r)


n = int(input())
k = int(input())
A = 1
for i in range(n):
	if A < k:
		A *= 2
	else:
		A += k
print(A)


N = int(input())
K = int(input())
a = 1
for n in range(N):
	a = min(a + K, 2 * a)
print(a)


N = int(input())
K = int(input())
ans = 1
for i in range(N):
	ans += min(ans, K)
print(ans)


(N, K) = map(int, open(0))
L = 1
for i in range(N):
	L += min(L, K)
print(L)


n = int(input())
k = int(input())
m = 1
for i in range(n):
	m += min(m, k)
print(m)


N = int(input())
K = int(input())
a = 1
for i in range(N):
	if a < K:
		a *= 2
	else:
		a += K
print(a)


n = int(input())
k = int(input())
t = 1
while t < k and n > 0:
	t += t
	n -= 1
while n > 0:
	t += k
	n -= 1
print(t)


N = int(input())
K = int(input())
Ans = 1
for _ in range(N):
	Ans = min(Ans * 2, Ans + K)
print(Ans)


N = int(input())
K = int(input())
num = 1
for _ in range(N):
	num += min(num, K)
print(num)


n = int(input())
k = int(input())
given_integer = 1
for i in range(0, n):
	given_integer = min(given_integer * 2, given_integer + k)
print(int(given_integer))


n = int(input())
k = int(input())
a = 1
for n in range(n):
	a += min(a, k)
print(a)


N = int(input())
K = int(input())
start = 1
for i in range(N):
	start = min(start * 2, start + K)
print(str(start))


n = int(input())
k = int(input())
x = 1
for _ in range(n):
	x = min(2 * x, x + k)
print(x)


(n, k, b) = (int(input()), int(input()), 1)
for _ in [0] * n:
	b += min(b, k)
print(b)


N = int(input())
K = int(input())
ans = 1000
for i in range(N + 1):
	num = 1
	for s in range(i):
		num = num * 2
	for t in range(N - i):
		num += K
	if num < ans:
		ans = num
print(ans)


n = int(input())
k = int(input())
x = 1
for i in range(n):
	x += min([x, k])
print(x)


N = int(input())
K = int(input())
X = 1
for i in range(N):
	if X < K:
		X += X
	else:
		X += K
print(X)


N = int(input())
K = int(input())
num = 1
for i in range(N):
	num += min(num, K)
print(num)


N = int(input())
K = int(input())
out = 1
flg = 0
for i in range(N):
	if not flg:
		out *= 2
		if out > K:
			flg = 1
	else:
		out += K
print(out)


n = int(input())
k = int(input())
from itertools import product
pr = list(product([0, 1], repeat=n))
ans = float('inf')
for p in pr:
	tmp = 1
	for i in p:
		if i == 0:
			tmp *= 2
		else:
			tmp += k
	ans = min(ans, tmp)
print(ans)


N = int(input())
K = int(input())
cnt = 1
for i in range(N):
	cnt += min(cnt, K)
print(cnt)


N = int(input())
K = int(input())
ans = 1
for k in range(N):
	ans = min(ans * 2, ans + K)
print(ans)


n = int(input())
m = int(input())
s = 1
for i in range(n):
	s = min(s * 2, s + m)
print(s)


import math
ans = 1
count = 0
num1 = int(input())
num2 = int(input())
for i in range(num1):
	if ans < num2:
		ans *= 2
	else:
		ans += num2
print(ans)


(n, k) = (int(input()), int(input()))
a = 1
while a <= k:
	if n == 0:
		print(a)
		return
	a *= 2
	n -= 1
while n > 0:
	a += k
	n -= 1
print(a)


n = int(input())
k = int(input())
ans = 1
for x in range(n):
	ans += min(ans, k)
print(ans)


n = int(input())
k = int(input())
s = 1
for i in range(n):
	s += min(k, s)
print(s)


n = int(input())
k = int(input())
ans = 1
for _ in range(n):
	ans += min(ans, k)
print(ans)


n = int(input())
k = int(input())
a = 1
for _ in [0] * n:
	a += min(a, k)
print(a)


n = int(input())
k = int(input())
i = 0
while i < n and 2 ** i <= k:
	i += 1
print(2 ** i + k * (n - i))


N = int(input())
K = int(input())
start = 1
for i in range(N):
	start_a = start * 2
	start_b = start + K
	if start_a <= start_b:
		start = start_a
	else:
		start = start_b
print(start)


import sys
input = sys.stdin.readline
N = int(input())
K = int(input())
c = 0
tmp = 1
while c < N:
	if tmp < K:
		tmp *= 2
	else:
		tmp += K
	c += 1
print(tmp)


N = int(input())
K = int(input())
ans = 1
while ans < K and N > 0:
	ans *= 2
	N -= 1
print(ans + N * K)


(n, k) = [int(input()) for _ in range(2)]
result = 10 ** 9
for bit in range(2 ** n):
	tmp = 1
	for i in range(n):
		if bit & 1 << i:
			tmp *= 2
		else:
			tmp += k
	result = min(result, tmp)
print(result)


a = int(input())
b = int(input())
x = 1
for i in range(a):
	if x + b > x * 2:
		x = x * 2
	else:
		x = x + b
print(x)


n = int(input())
k = int(input())
ans = 1
while n > 0:
	ans = min(2 * ans, ans + k)
	n -= 1
print(ans)


A = int(input())
B = int(input())
z = 1
for i in range(A):
	if z + B < 2 * z:
		z = z + B
	else:
		z = 2 * z
print(z)


(n, k) = (int(input()) for i in range(0, 2))
ans = 1
for i in range(0, n):
	if ans * 2 <= ans + k:
		ans *= 2
	else:
		ans += k
print(ans)


from functools import reduce

def operator(x, K, N):
	res = (lambda x: 2 * x if x < K else x + K)(x)
	return res if N == 1 else operator(res, K, N - 1)

def main():
	with open(0) as f:
		(N, K) = list(map(int, f.read().split()))
	ans = operator(1, K, N)
	print(ans)
main()


n = int(input())
k = int(input())
cnt = 1
tmp = 0
for i in range(n):
	cnt = min(cnt * 2, cnt + k)
print(cnt)


n = int(input())
k = int(input())
res = 1
for _ in range(n):
	res += min(res, k)
print(res)


n = int(input())
k = int(input())
x = 1
i = 0
while i < n:
	i += 1
	x = min(2 * x, k + x)
print(x)


def solve():
	n = int(input())
	k = int(input())
	ans = 1
	for i in range(n):
		if ans < k:
			ans *= 2
		else:
			ans += k
	print(ans)

def __starting_point():
	solve()
__starting_point()


(n, k, w) = (int(input()), int(input()), 1)
for _ in range(n):
	w += min(w, k)
print(w)


(n, k) = map(int, open(0))
r = 1
exec('r+=min(r,k);' * n)
print(r)


N = int(input())
K = int(input())
ans = float('inf')
for i in range(N + 1):
	num = 1 * 2 ** i + K * (N - i)
	ans = min(ans, num)
print(ans)


N = int(input())
K = int(input())
a = 1
for i in range(N):
	a += min(a, K)
print(a)


import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

def I():
	return int(input())

def F():
	return float(input())

def SS():
	return input()

def LI():
	return [int(x) for x in input().split()]

def LI_():
	return [int(x) - 1 for x in input().split()]

def LF():
	return [float(x) for x in input().split()]

def LSS():
	return input().split()

def resolve():
	N = I()
	K = I()
	ans = 1
	while ans < K and N > 0:
		ans *= 2
		N -= 1
	ans += N * K
	print(ans)

def __starting_point():
	resolve()
__starting_point()


N = int(input())
K = int(input())
ans = 1
for _ in range(N):
	ans += min(ans, K)
print(ans)


import sys
sys.setrecursionlimit(10 ** 6)
n = int(input())
k = int(input())
ans = 1
for i in range(n):
	if ans * 2 <= ans + k:
		ans *= 2
	else:
		ans += k
print(ans)


n = int(input())
k = int(input())
t = 1
for i in range(n):
	t = min(t + t, t + k)
print(t)


N = int(input())
K = int(input())
x = 1
for _ in range(N):
	x += min(x, K)
print(x)


import math
(n, k) = (int(input()), int(input()))
c = int(math.log2(k)) + 1
d = min(n, c)
print(2 ** d + (n - d) * k)


n = int(input())
k = int(input())
c = 1
for i in range(n):
	c += min(c, k)
print(c)


(n, k) = eval('int(input()),' * 2)
r = 1
for _ in [0] * n:
	r += min(r, k)
print(r)


ans = float('inf')
(n, k) = (int(input()), int(input()))
for i in range(2 ** n):
	ans = min(ans, eval('(' * n + '1' + ''.join(('*2)' if (i >> j) % 2 else '+' + str(k) + ')' for j in range(n)))))
print(ans)


a = int(input())
b = int(input())
num = 1
for _ in range(a):
	num = min(num * 2, num + b)
print(num)


(n, k) = (int(input()), int(input()))
ans = 1
i = 0
while i != n:
	if ans >= k:
		ans += k
	else:
		ans *= 2
	i += 1
print(ans)


n = int(input())
k = int(input())
ans = 1
for i in [0] * n:
	ans += min(ans, k)
print(ans)


N = int(input())
K = int(input())
ans = 1

def A(n):
	return 2 * n

def B(n):
	return n + K
for i in range(N):
	if A(ans) <= B(ans):
		ans = A(ans)
	else:
		ans = B(ans)
print(ans)


(n, k) = map(int, open(0))
a = 1
while a < k and n:
	a *= 2
	n -= 1
print(a + k * n)


n = int(input())
k = int(input())
num = 1
count = 0
while count < n:
	num = min(num * 2, num + k)
	count += 1
print(num)


(n, k) = (int(input()), int(input()))
s = 1
while n:
	s += min(s, k)
	n -= 1
print(s)


N = int(input())
K = int(input())
j = 1

def func(x, y):
	r = x * 2 if x * 2 < x + y else x + y
	return r
for i in range(N):
	j = func(j, K)
print(j)


a = int(input())
b = int(input())
c = 1
for i in range(a):
	c += min(b, c)
else:
	print(c)


a = int(input())
b = int(input())
p = len(format(b, 'b'))
print(2 ** min(a, p) + b * max(a - p, 0))


def answer(n: int, k: int) -> int:
	current_num = 1
	for _ in range(n):
		current_num = min(current_num * 2, current_num + k)
	return current_num

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

def __starting_point():
	main()
__starting_point()


N = int(input())
K = int(input())
val = 1
for i in range(N):
	val += min(val, K)
print(val)


(n, k) = map(int, open(0).read().split())
a = 1
for i in range(n):
	a = min(a * 2, a + k)
print(a)