Problem:


Score : 400 points

Problem Statement

Snuke has one biscuit and zero Japanese yen (the currency) in his pocket.
He will perform the following operations exactly K times in total, in the order he likes:

Hit his pocket, which magically increases the number of biscuits by one.

Exchange A biscuits to 1 yen.

Exchange 1 yen to B biscuits.

Find the maximum possible number of biscuits in Snuke's pocket after K operations.

Constraints

1 \leq K,A,B \leq 10^9

K,A and B are integers.

Input

Input is given from Standard Input in the following format:

K A B

Output

Print the maximum possible number of biscuits in Snuke's pocket after K operations.

Sample Input 1

4 2 6

Sample Output 1

7

The number of biscuits in Snuke's pocket after K operations is maximized as follows:

Hit his pocket. Now he has 2 biscuits and 0 yen.

Exchange 2 biscuits to 1 yen. his pocket. Now he has 0 biscuits and 1 yen.

Hit his pocket. Now he has 1 biscuits and 1 yen.

Exchange 1 yen to 6 biscuits. his pocket. Now he has 7 biscuits and 0 yen.

Sample Input 2

7 3 4

Sample Output 2

8

Sample Input 3

314159265 35897932 384626433

Sample Output 3

48518828981938099



Sample input:
4 2 6


Sample output:
7

Submission status: Wrong Answer

Solution code:
a=[]#入力画面の二文字を別々の文字に格納
a=input().split(" ")
K=int(a[0])
A=int(a[1])
B=int(a[2])
d=K-A
b=B+1
if A+1>=B :
    x=1+K
    print(x)
elif d%2==0:
    if K==A+2:
        print(B+1)
    else:
        x1=(d-2)*(B-A)*(1/2)+B+1
        print(int(x1))
elif d%2==1:
    if K==A+1:
        print(B)
    else:
        x2=(d-1)*(B-A)*(1/2)+B
        print(int(x2))

Submission status: Wrong Answer

Solution code:
s = input().split()
K = int(s[0])
A = int(s[1])
B = int(s[2])

bis = 1

if float(B/A) > 2:
  change = 1
else:
  change = 0

if change == 0:
  bis = bis + K
else:
  i = A-1
  bis = bis + i
  k = K - i
  bis += (k//2)*(B-A)
  bis += bis%2
print(bis)

Submission status: Wrong Answer

Solution code:
k, a, b = map(int, input().split())

# ビスケットの売値が買値より安い場合
if a+2 > b:
    print(1 + k)
    exit()

# 交換獲得に必要なターン数
roop_turn = a+2

# 初回時ビスケット１枚を余分に所持
if k < roop_turn-1:
    print(1 + k)
    exit()

# 獲得ビスケット
ret = b

# 残りターン
remaining = k - roop_turn-1

q, mod = divmod(remaining, 2)

ret += (b-a)*q + mod
print(ret)

Submission status: Wrong Answer

Solution code:
import math
K,A,B = map(int, input().split())
cookie = 0

if K < A - 1 or B - A <  A  or B - A < 2:
    print(K + 1)

else:
    cookie = B
    K = K-A-1

    if K%2==0:
        cookie += (B-A)* math.floor(K/2)
        print(cookie)
    else:
        cookie += (B-A)*math.floor((K-1)/2)
        print(cookie + 1)

Submission status: Wrong Answer

Solution code:
K, A, B = input().split()
K = int(K)
A = int(A)
B = int(B)
N = 1

if A+2 > B:
    N = N + K
else:
    # ビスケットを金にする価値がある
    if K > (A + 1):
        # 1回目
        K = K - (A + 1)
        N = B
        # 売る買うを繰り返す?
        if K % 2 == 0:
            N = N + (B*K//2) - (A*K//2)
        else:
            K = K - 1
            N = N + (B*K//2) - (A*K//2) + 1
    else:
        N = N + K
print(N)

Submission status: Wrong Answer

Solution code:
a=[]#入力画面の二文字を別々の文字に格納
a=input().split(" ")
K=int(a[0])
A=int(a[1])
B=int(a[2])
d=K-A
b=B+1
if A+1>=B :
    x=1+K
    print(x)
elif d%2==0:
    if K==A+2:
        print(B+1)
    else:
        x1=(d-2)*(B-A)*(1/2)+B+1
        print(int(x1))
elif d%2==1:
    if K==A+1:
        print(B)
    else:
        x2=(d-1)*(B-A)*(1/2)+B+3
        print(int(x2))

Submission status: Wrong Answer

Solution code:
import math
K,A,B = map(int, input().split())
cookie = 0

if K < A - 1 or B - A <  A + 1 or B - A < 2:
    print(K + 1)

else:
    cookie = B
    K = K-A-1

    if K%2==0:
        cookie += (B-A)* math.floor(K/2)
        print(cookie)
    else:
        cookie += (B-A)*math.floor((K-1)/2)
        print(cookie + 1)

Submission status: Wrong Answer

Solution code:
a=[]#入力画面の二文字を別々の文字に格納
a=input().split(" ")
K=int(a[0])
A=int(a[1])
B=int(a[2])
d=K-A
b=B+1
if A+1>=B :
    x=1+K
    print(x)
elif d%2==0:
    if K==A+2:
        print(B+1)
    else:
        x1=(d-2)*(B-A)*(1/2)+B+1+3
        print(int(x1))
elif d%2==1:
    if K==A+1:
        print(B)
    else:
        x2=(d-1)*(B-A)*(1/2)+B+3
        print(int(x2))

Submission status: Wrong Answer

Solution code:
k,a,b = map(int,input().split())
print(k + 1 if a + 1>= b else b + ((k - (a + 1)) % 2) +  (b - a) * int((k - (a + 1)) / 2))

Submission status: Wrong Answer

Solution code:
a=input()
K=int(a.split()[0])
A=int(a.split()[1])
B=int(a.split()[2])

b=K-(A-1)
c=int(b/2)
if(b%2==0):
  d=c*B
  ans=d+(A-1)
  print(ans)
else:
  d=c*(B-1)
  ans=d+(A-1)
  print(ans)

Submission status: Wrong Answer

Solution code:
def read():
    return int(input())

def reads():
    return list(map(int, input().split()))

k,a,b=reads()
k2 = 0
if (b-a)/2 <= 1:
    print(1+k)
else:
    k2 = k-a+1
    if k2 >= 2:
        if k2 % 2 == 0:
            print(int(a + (b-a)*k2/2)+3)
        else:
            print(int(a + (b-a)*(k2-1)/2 + 1))
    else:
        print(2+k)

Submission status: Wrong Answer

Solution code:
a,b,c = input().split( )
a=int(a)
b=int(b)
c=int(c)
if a<b+1:
  print(a+1)  
elif b < c-2:
  if (b-a+1)%2 ==0:
    print((c-b)*(a-b+1)/2+b)
  else:
    print((c-b)*(a-b)/2+1+b)
else:
  print(a+1)

Submission status: Wrong Answer

Solution code:

K, A, B = map(int, input().split())

need_turns = A + 1 + 1  # 交換に必要なターン
first_need_turns = need_turns - 1

if A + 2 > B or K < first_need_turns:  # 交換せずにビスケットを叩き続ける方が得
    print(1 + K)
    exit()

ans = B  # 一度交換した
K -= (need_turns - 1)

# print("{}, {}".format(K, ans))

while K >= 0:
    if ans >= A and K >= 2:
        ans += (B - A) * K / 2
        K = 0
    else:
        ans += 1
        K -= 1

print(ans)

Submission status: Wrong Answer

Solution code:
# C When I hit my pocket
k,a,b = map(int,input().split())

bis = 1

#if k <= 1 or b <= a + 2 or k <= a + 1:
if k <= 1 or b <= a + 2:
    print(1 + k)
    exit()
else:
    bis = b
    k = k - ( a + 1)
    if not k == 0:
        bis += int(k / 2) * (b - a) + k % 2

print(bis)

Submission status: Wrong Answer

Solution code:
K, A, B = input().split()
K = int(K)
A = int(A)
B = int(B)
N = 1

if A+2 > B:
    N = N + K
else:
    # ビスケットを金にする価値がある
    if K > (A + 1):
        # 1回目
        K = K - (A + 1)
        N = B
        # 売る買うを繰り返す?
        if K % 2 == 0:
            N = N + (B*K//2) - (A*K//2)
        else:
            K = K - 1
            N = N + (B*K//2) - (A*K//2) + 1
    else:
        N = N + K
print(int(N))

Submission status: Wrong Answer

Solution code:

K,A,B=[int(_) for _ in input().split()]
if  B < A+2 or K <= A+1 :
    print(K+1)
else:
    d = (K+1) - (A+2)
    d = (d // 2) * (B-A)  + (d%2)
    print( d + B)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
k,a,b = map(int, input().split())

if a >= b:
  print(k+1)
else:
  t=((k+1)//(a+2))
  r=(k+1)-t*(a+2)
  if a < (b-a):
    nn = (k+1)-a
    print(nn//2*(b-a)+a+((k+1)-a)%2) 
  else:
    print(max(t*b+r,k+1))

Submission status: Wrong Answer

Solution code:
K, A, B = map(int, input().split())
if A + 2 > B:
    print(K+1)
    exit()


bis = 0
K = K - (A+1)
bis = B

if B - A >= 2:
    if K > 1:
        k = K//2
        bis += (B-A)*k

    if K % 2 == 1:
        bis += 1

print(bis)

Submission status: Wrong Answer

Solution code:
s = input().split()
K = int(s[0])
A = int(s[1])
B = int(s[2])

bis = 1

if float(B/A) > 2:
  change = 1
else:
  change = 0

if change == 0:
  bis = bis + K
else:
  i = A-1
  bis = bis + i
  k = K - i
  bis += (B-A)*k//2
print(bis)

Submission status: Wrong Answer

Solution code:

K, A, B = map(int, input().split())

need_turns = A + 1 + 1  # 交換に必要なターン
first_need_turns = need_turns - 1

if A + 2 > B or K < first_need_turns:  # 交換せずにビスケットを叩き続ける方が得
    print(1 + K)
    exit()

ans = B  # 一度交換した
K -= (need_turns - 1)

# print("{}, {}".format(K, ans))

while K >= 0:
    if ans >= A and K >= 2:
        ans += (B - A) * K / 2
        K = 0
        # print("aa")
    else:
        ans += 1
        K -= 1
        # print("bb")

Submission status: Wrong Answer

Solution code:
K, A, B = input().split()
K = int(K)
A = int(A)
B = int(B)
N = 1

if A+2 > B:
    N = N + K
else:
    # ビスケットを金にする価値がある
    if K > (A + 1):
        # 1回目
        K = K - (A + 1)
        N = B
        # 売る買うを繰り返す?
        if K % 2 == 0:
            N = N + (B*K/2) - (A*K/2)
        else:
            K = K - 1
            N = N + (B*K/2) - (A*K/2) + 1
    else:
        N = N + K
print(int(N))

Submission status: Wrong Answer

Solution code:
def function(K, A, B):
	bis = 1
	get_bis = 0
	coin = 0
	if B - A > 1:
		b = K - (A+1)
		c = (int(b/(A+2)))*B
		d = b%(A+2)
		print(c + d + B)

	else:
		print(K + 1)

def main():
	nums = input().split(' ')
	function(int(nums[0]), int(nums[1]), int(nums[2]))

if __name__ == '__main__':
	main()

Submission status: Wrong Answer

Solution code:
# coding: utf-8
K, A, B = list(map(int, input().split()))
if B - A > 2 and K - A > 1:
    x = (K - A + 1) // 2
    y = (K - A + 1) % 2
    if x < 2:
        print(B + y)
    else:
        print(x * (B - A) + A + y)
else:
    print(K + 1)

Submission status: Wrong Answer

Solution code:
K, A, B = map(int, input().split())

res = 0
if A + 2 >= B or K <= A + 1:
    res += K + 1
else:
    res += B
    K -= A + 1
    res += (K // 2) * (B - A) + (K % 2)

print(res)

Submission status: Wrong Answer

Solution code:
N = list(map(int, input().split()))

K = N[0]
A = N[1]
B = N[2]

if B - A <= 2:
  print(K+1)
  exit()

bis = 0

if (K-A)%2==1:
  for _ in range(int((K-A)/2+1)):
    bis += B
    bis -= A
  bis += A
else:
  for _ in range(int((K-A)/2)-1):
    bis += B
    bis -= A
  bis += B
  bis += 1

print(bis)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
K,A,B=map(int,input().split())



if A + 1 < B:
    bis = 1
    add = B - A # 増える数
    moving = (K//A) -1 #交換可能回数
    if moving > 0:
        #print("m")
        bis = B
        K-=A+1
    if moving == 0:
        print(K+1)
        exit()
    #print(bis)
    
    bis+=add*(K // 2)
    if K % 2 != 0:
        bis+=1
    #print(bis,moving)
    print(bis)
    
else:
    print(K+1)

Submission status: Wrong Answer

Solution code:
k,a,b=[int(p) for p in input().split()]
if(a+2>=b or k/(a+2)<1 or 2*a+2==b):
    print(k+1)
elif(2*a+2>b):
    print(1+k+(int((1+k)/(2*a-b+2)))*(b-a-2))
else:
    print(1+k+(int((1+k-a)/2))*(b-a-2))

Submission status: Wrong Answer

Solution code:
def function(K, A, B):
	bis = 1
	get_bis = 0
	coin = 0
	if B - A > 1:
		b = K - (A+1)
		if b >= (A+2):
			c = (int(b/(A+2)))*B
			d = b%(A+2)
			print(c + d + B)
		else:
			print(B + b - 1)

	else:
		print(K + 1)

def main():
	nums = input().split(' ')
	function(int(nums[0]), int(nums[1]), int(nums[2]))

if __name__ == '__main__':
	main()

Submission status: Wrong Answer

Solution code:
import math
K,A,B = map(int, input().split())
cookie = 0

if K < A -1 or B - A < 2 + A - 1:
    print(K + 1)

else:
    cookie = B
    K = K-A-1

    if K%2==0:
        cookie += (B-A)* math.floor(K/2)
        print(cookie)
    else:
        cookie += (B-A)*math.floor((K-1)/2)
        print(cookie + 1)

Submission status: Wrong Answer

Solution code:
K, A, B = map(int, input().split())
# snuke can biscket add otr huyasu


bis = 1
ad = B - A
starts = 2
if (B - A) > 1:
    bis = A
    K -= (A - 1)
    if K <= 1:
        print(K + 1)
        exit(0)
    mades = int(K / 2)
    if (K /2- mades) != 0:
        bis += 1
    bis += (mades * ad)
    print(bis)
    exit(0)
else:
    print(K + 1)
    exit(0)

Submission status: Wrong Answer

Solution code:
K, A, B = map(int, input().split())
if A + 2 > B:
    print(K+1)
    exit()

bis = 0
K = K - (A+1)
bis = B

if K < 2:
    bis += 1
    print(bis)
    exit()

if B - A > 2:
    if K > 1:
        k = K//2
        bis += (B-A)*k

    if K % 2 == 1:
        bis += 1

print(bis)

Submission status: Wrong Answer

Solution code:
a,b,c = input().split( )
a=int(a)
b=int(b)
c=int(c)
if a<b:
  print(a+1)  
elif b < c+2:
  if (b-a+1)%2 ==0:
    print((c-b)*(a-b+1)/2+b)
  else:
    print((c-b)*(a-b)/2+1+b)
else:
  print(a+1)

Submission status: Wrong Answer

Solution code:
from math import ceil
K, A, B = map(int, input().split())
b = 1

if B - A > 2:
    b += min(A - 1, K)
    K -= min(A - 1, K)
    if K == 0:
        print(b)
        exit()
    n = K // 2
    b += n * (B - A)
    n += K
    print(b)
else:
    b += K
    print(b)

Submission status: Wrong Answer

Solution code:
k,a,b = map(int,input().split())
bis = 1
if 1+k<a or b-a<=1 or a>b or k==1:
    bis = 1+k
elif (k-(a-1))%2==0:
    bis = (b+(b-a)*((k-(a-1))//2-1))
else:
    bis = (a-1)+(b+(b-a)*((k-(a-1))//2-1))
print(bis+1)

Submission status: Wrong Answer

Solution code:
import sys
K,A,B = [int(n) for n in input().split()]
# N = int(input())
ans = 1
print(int(K/A)*B)
if(A+2 <= B and K >= A+2):
    if(K%A >=2):
        ans+=int(K/A)*B
        K%=A
        K-=2
    else:
        ans+=(int(K/A)-1)*B
        K%=A
        K+=A
        K-=2
print(ans+K)

Submission status: Wrong Answer

Solution code:
import math
K,A,B = map(int, input().split())
cookie = 0

if K <= A -1 or B - A < 2 + A - 1:
    print(K + 1)

else:
    cookie = B
    K = K-A-1

    if K%2==0:
        cookie += (B-A)* math.floor(K/2)
        print(cookie)
    else:
        cookie += (B-A)*math.floor((K-1)/2)
        print(cookie + 1)

Submission status: Wrong Answer

Solution code:
k,a,b = map(int,input().split())
bis = 1
if 1+k<a or b-a<=1 or a>b or k==1:
    bis = 1+k
elif (k-(a-1))%2==0:
    bis = (b+(b-a)*((k-(a-1))//2-1))
else:
    bis = (a-1)+(b+(b-a)*((k-(a-1))//2-1))
print(bis)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
K,A,B=map(int,input().split())



if A + 2 < B:
    bis = 1
    add = B - A # 増える数
    moving = (K//A) -1 #交換可能回数
    if moving > 0:
        print("m")
        bis = B
        K-=A+1
    if moving == 0:
        print(K+1)
        exit()
    #print(bis)
    
    bis+=add*(K // 2)
    if K % 2 != 0:
        bis+=1
    #print(bis,moving)
    print(bis)
    
else:
    print(K+1)

Submission status: Wrong Answer

Solution code:
n,A,B=map(int,input().split())

bis=1
en=0

if A+2>=B:
  ans=bis+n
else:
  if (n+1)>=(A+2):
    #はじめの交換
    n-=(A-1)+2
    en+=1+n//2
    #print(en,n)
    bis+=n%2+en*B-1
    n=0
  if n==0:
    ans=bis
  else:
    ans=bis+n
print(ans)

Submission status: Wrong Answer

Solution code:
K, A, B = map(int, input().split())
if A + 2 > B:
    print(K+1)
    exit()

bis = 0
K = K - (A+1)
bis = B

if B - A > 2:
    if K > 1:
        k = K//2
        bis += (B-A)*k

    if K % 2 == 1:
        bis += 1

print(bis)

Submission status: Wrong Answer

Solution code:
def func():
    pass


def main():
    k, a, b = map(int, input().split())

    i = 0
    c = 1
    while i < k:
        if c >= a and (k - i - 1) >= 2:
            # print("2:", i, c)
            c = c - a + b
            i += 1
        else:
            # print("3:", i, c)
            c += 1
        i += 1

    print(c)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(200000)


def input():
    return sys.stdin.readline()[:-1]


def ii(t: type = int):
    return t(input())


def il(t: type = int):
    return list(map(t, input().split()))


def imi(N: int, t: type = int):
    return [ii(t) for _ in range(N)]


def iml(N: int, t: type = int):
    return [il(t) for _ in range(N)]


def solve():
    K, A, B = il()
    ka = K - A
    ans = (ka // 2) * (B - A)
    if ka % 2 == 1:
        ans += B
    else:
        ans -= B

    s, t = divmod(K - 1, A)
    bis = s + t * B
    return max(bis, K + 1, ans)


if __name__ == "__main__":
    print(solve())

Submission status: Wrong Answer

Solution code:
import math
K,A,B = map(int, input().split())
cookie = 0

if K <= A or B - A < 2 + A - 1:
    print(K + 1)

else:
    cookie = B
    K = K-A-1

    if K%2==0:
        cookie += (B-A)* math.floor(K/2)
        print(cookie)
    else:
        cookie += (B-A)*math.floor((K-1)/2)
        print(cookie + 1)

Submission status: Wrong Answer

Solution code:
k,a,b = map(int,input().split())
bis = 1
cnt = 0
if 1+k<a or b-a<=1 or a>b or k==1:
    bis = 1+k
if (k-(a-1))%2==0:
    bis = (b+(b-a)*((k-(a-1))//2-1))
else:
    bis = (a-1)+(b+(b-a)*((k-(a-1))//2-1))
print(bis)

Submission status: Wrong Answer

Solution code:
# C When I hit my pocket
k,a,b = map(int,input().split())

bis = 1
yen = 0

if k == 1 or b <= a + 2 or k <= a + 1:
    print(1 + k)
    exit()
else:
    bis = b
    k = k - ( a + 1)
    bis += int(k / 2) * (b - a) + k % 2

print(bis)

Submission status: Wrong Answer

Solution code:
K, A, B = map(int, input().split())

if not B - A <= 2:
    if not (A == K or A == K + 1):
        if (K - A - 1) // 2 == 0:
            print(B + (B - A) * ((K - A - 1) // 2) + 1)
        else:
            print(B + (B - A) * ((K - A - 1) // 2))
    else:
        print(K + 1)

else:
    print(K + 1)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
K,A,B=map(int,input().split())



if A + 2 < B:
    bis = 1
    add = B - A # 増える数
    moving = (K//A) -1 #交換可能回数
    if moving > 0:
        bis = B
        K-=A+1
    #print(bis)
    
    bis+=add*(K // 2)
    if K % 2 != 0:
        bis+=1
    #print(bis,moving)
    print(bis)
    
else:
    print(K+1)

Submission status: Wrong Answer

Solution code:
a,b,c = input().split( )
a=int(a)
b=int(b)
c=int(c)
if a<b:
  print(a+1)  
elif b < c+2:
  if (b-a+1)%2 ==0:
    print((c-b)*(a-b+1)/2)
  else:
    print((c-b)*(a-b)/2+1)
else:
  print(a+1)

Submission status: Wrong Answer

Solution code:
import math
K,A,B = map(int, input().split())
cookie = 0

if K < A or B - A <= 2 + A - 1:
    print(K + 1)

else:
    cookie = B
    K = K-A-1

    if K%2==0:
        cookie += (B-A)* math.floor(K/2)
        print(cookie)
    else:
        cookie += (B-A)*math.floor((K-1)/2)
        print(cookie + 1)

Submission status: Wrong Answer

Solution code:
K,A,B=[int(_) for _ in input().split()]
if ( B <= A+2 and B+1 <= K) or K <= A+1 :
    print(K+1)
else:
    d = (K+1) - (A+2)
    d = (d // 2) * (B-A)  + (d%2)
    print( d + B)

Submission status: Wrong Answer

Solution code:
# C When I hit my pocket
k,a,b = map(int,input().split())

bis = 1
yen = 0

if b <= a + 2 or k <= a + 1:
    print(1 + k)
    exit()
else:
    bis = b
    k = k - ( a + 1)
    
    bis += int(k / 2) * (b - a) + k % 2
    
#    for i in range(k):        
#        if not yen == 0:
#            bis += b
#            yen -= 1
#        elif k - i - 1 > 0 and bis >= a:
#            bis -= a
#            yen += 1
#        else:
#            bis += 1
            
print(bis)

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(200000)


def input():
    return sys.stdin.readline()[:-1]


def ii(t: type = int):
    return t(input())


def il(t: type = int):
    return list(map(t, input().split()))


def imi(N: int, t: type = int):
    return [ii(t) for _ in range(N)]


def iml(N: int, t: type = int):
    return [il(t) for _ in range(N)]


def solve():
    K, A, B = il()
    ka = K - A
    ans = (ka // 2) * (B - A)
    if ka % 2 == 1:
        ans += B

    s, t = divmod(K - 1, A)
    bis = s + t * B
    return max(bis, K + 1, ans)


if __name__ == "__main__":
    print(solve())

Submission status: Wrong Answer

Solution code:
k,a,b=map(int,input().split())
if k-1>a:
  if b-a>1:
    k=k-a-1
    print((b + int(k/2)*(b-a) + k%2))
  else:
    print(1+k)
else:
  print(1+k)

Submission status: Wrong Answer

Solution code:
k,a,b = map(int,input().split())
bis = 1
cnt = 0
if 1+k<a or b-a<=2 or a>b:
    bis = 1+k
if (k-(a-1))%2==0:
    bis = (b+(b-a)*((k-(a-1))//2-1))
else:
    bis = (a-1)+(b+(b-a)*((k-(a-1))//2-1))
print(bis)

Submission status: Wrong Answer

Solution code:
k, a, b = map(int, input().split())

def main(k, a, b):
    if k + 1 < a + 1:
        return k + 1

    dif = b - a
    


    if b > a + 2:
        if k + 1 == a + 2:
            return b + (k-a+1)//(a + 2) * b + (k-a+1) % (a + 2)
        else:
            return k//(a + 2) * b + k % (a + 2) + 1
    
    else:
        return k + 1


print(main(k, a, b))

Submission status: Wrong Answer

Solution code:
i = input().split()
k = int(i[0])
a = int(i[1])
b = int(i[2])

biscuits = 1
coin = 0

is_profitable = (b / a) > 1

if is_profitable:
    for i in range(k):
        if coin > 0:
            coin -= 1
            biscuits += b
        else:
            if biscuits >= a and i + 1 < k:
                coin += 1
                biscuits -= a
            else:
                biscuits += 1
else:
    biscuits += k

print(biscuits)

Submission status: Wrong Answer

Solution code:
K, A, B = map(int, input().split())

if (B - A) / 2 <= 1 or K < A + 2: # ビスケットを叩くのが良い
    print(K + 1)
else: # ビスケットを交換した方が良い
    n = (K - A - 1)
    if n % 2 == 0:
        print(B + (B-A)*n/2)
    else:
        print(B + (B-A)*int(n/2) + 1)

Submission status: Wrong Answer

Solution code:
def read():
    return int(input())

def reads():
    return list(map(int, input().split()))

k,a,b=reads()
k2 = 0
if (b-a)/2 <= 1:
    print(1+k)
else:
    k2 = k-a+1
    if k2 >= 2:
        if k2 % 2 == 0:
            print(int(a + (b-a)*k2/2))
        else:
            print(int(a + (b-a)*(k2-1)/2 + 1))
    else:
        print(1 + k)

Submission status: Wrong Answer

Solution code:
k, a, b = [int(i) for i in input().split()]

sum = 0
if a >= b:
    # A >= Bの場合
    sum = k + 1
else:
    # A < B の場合
    diff = b - a
    if diff == 1:
        sum = k + 1
    elif diff == 2:
        sum = k + 1
    else:
        # a->bコンボが利潤を生み続けるパターン
        k = 1 + k - a
        if k % 2 == 0:
            sum = a + ((diff) * (k / 2))
        else:
            # 最後1回はコンボができないので、叩くパターン
            sum = a + ((diff) * ((k - 1) / 2)) + 1

print(int(sum))

Submission status: Wrong Answer

Solution code:
k,a,b = map(int,input().split())
bis = 1
cnt = 0
if (k-(a-1))%2==0:
    bis = (b+(b-a)*((k-(a-1))//2-1))
else:
    bis = (a-1)+(b+(b-a)*((k-(a-1))//2-1))
print(max(bis,1+k))

Submission status: Wrong Answer

Solution code:
bis=0
yen=0

k,a,b=map(int,input().split())

k_num =k #残り回数
n=b-a #クッキーを円を経由することにより増える枚数

k_num-=(a-1) #円に交換できるまでクッキーを増やす

func_num=k_num/2 #交換できる回数
func_num=int(func_num)
#print(func_num)
add_bis=func_num*n #増やせたクッキーの数
#print(add_bis)
if(k_num%2==1): #奇数なので最後に割っとく
    bis +=1

#print(bis)

if(k<3 or k<(a+2) or n<3):
    print(k+1)
else:
    print(bis+add_bis + a)

Submission status: Wrong Answer

Solution code:
K,A,B = [int(i) for i in input().split()]

if (B-A < 2+A):
    print(K+1)
    exit(0)

else:
    t = int((K-A+1)/2)
    ans = t * (B-A) + A + ((K-A+1)%2)
    print(ans)

Submission status: Wrong Answer

Solution code:
k, a, b = map(int, input().split())
biscuit = 1
tmp = 1

if b <= a or k < a or (b - a) / 2 < 1:
    print(k + 1)
    exit()
else:
    biscuit += (a - 1)
    k -= (a - 1)

print((b - a) * (k // 2) + biscuit + ((k+a-1)%2==0 &1))

Submission status: Wrong Answer

Solution code:
k,a,b=[int(p) for p in input().split()]
if(a+2>b or (k)/(a+2)<1):
    print(k+1)
elif(2*a+2>b):
    print(1+k+(int((1+k)/(2*a-b+2)))*(b-a-2))
else:
    print(1+k+(int((1+k-a)/2))*(b-a-2))

Submission status: Wrong Answer

Solution code:
k, a, b = [int(i) for i in input().split()]

sum = 0
if a >= b:
    # A >= Bの場合
    sum = k + 1
else:
    # A < B の場合
    diff = b - a
    if diff == 1:
        sum = k + 1
    elif diff == 2:
        sum = k + 1
    else:
        # a->bコンボが利潤を生み続けるパターン
        k = 1 + k - a
        if k % 2 == 0:
            sum = a + ((diff) * (k / 2))
        else:
            # 最後1回はコンボができないので、叩くパターン
            sum = a + ((diff) * ((k - 1) / 2)) + 1

print(sum)

Submission status: Wrong Answer

Solution code:
s = input().split()
K = int(s[0])
A = int(s[1])
B = int(s[2])

bis = 1

if float(B/A) > 2:
  change = 1
else:
  change = 0

i = 0
while i < K:
  if change == 1:
    if bis >= A and i+1 < K:
      bis = bis - A + B
      i += 1
      continue
  bis = bis+1
  i += 1
 
print(bis)

Submission status: Wrong Answer

Solution code:
K,A,B = map(int, input().split(" "))


bis = 1

kaisu = 0

en = 0

if B <= A +  1:
    bis = bis + K
elif K+1 <= A:
    bis = bis + K
else:
    K = K - (A - 1)
    bis = A
    K = K - 2
    bis = B
    #while K >= 2:
        #if B-A <= K + 1:
        #   bis = bis + K + 1
    #    K = K - 2
    #    bis = bis - A + B
    if K % 2 == 0:
        w1 = int(K /2)
        w2 = B-A
        bis = bis + w1*w2
    else:
        w1 = int(K /2)
        w2 = B-A
        bis = bis + w1*w2 
        bis = bis +1


print(bis)

Submission status: Wrong Answer

Solution code:
k,a,b=map(int,input().split())

f=a-1+1+1
s=a+1+1

d=(k-f)//s
m=(k-f)%s

if b-a<2:
    print(1+k)
else:
    print(b*(d+1)+m)

Submission status: Wrong Answer

Solution code:
k,a,b = map(int, input().split())

bis_count = 0
k += 1
min_exchange_count = a+1+1

ope_count = k//min_exchange_count
amari_count = k%min_exchange_count

bis_count += amari_count
bis_count += ope_count*b

print(max([k,bis_count]))

Submission status: Wrong Answer

Solution code:
import numpy as np

def bis(y ,z, k, a, b):
    x = k - y - z
    if y >= z:
        return 1 + x - a*y + b*z
    else:
        return 0 
bis_univ = np.frompyfunc(bis, 5, 1)

k, a, b = [int(i) for i in input().split()]

Y = np.array([i for i in range((k-a+2)//2)])
Z = np.array([i for i in range((k-a+2)//2)])
yy, zz = np.meshgrid(Y, Z)

N = bis_univ(yy, zz, k, a, b)
print(np.amax(N))

Submission status: Wrong Answer

Solution code:
K,A,B = (int(x) for x in input().split())

if A >= B-1:
    ans = 1+K
else:
    if K <= A:
        ans = 1+K
    else:
        if (K-A+1)%2==0:
            ans = int(A+(B-A)*(K-A+1)/2)
        else:
            ans = int(1+A+(B-A)*(K-A)/2)
print(ans)

Submission status: Wrong Answer

Solution code:
k,a,b = map(int,input().split())
bis = 1
cnt = 0
if 1+k<a or b-a<=1 or a>b:
    bis = 1+k
elif (k-(a-1))%2==0:
    bis = (b+(b-a)*((k-(a-1))//2-1))
else:
    bis = (a-1)+(b+(b-a)*((k-(a-1))//2-1))
print(bis)

Submission status: Wrong Answer

Solution code:
k,a,b=map(int,input().split())
if a+2>=b or a+1>=k:
  print(1+k)
  exit()
k-=(a+1)
ma=b
if k==1:
  print(ma+1)
elif k%2==0:
  print(int(ma+(b-a)*(k//2)))
else:
  print(int(ma+(b-a)*((k-1)//2)+1))

Submission status: Wrong Answer

Solution code:
K, A, B = map(int,input().split())
if K < A+1 or B-A <= 2 :
    print(K+1)
else:
    t = (K - A - 1) //  2
    ans = B + t * (B - A) + 1
    print(ans)

Submission status: Wrong Answer

Solution code:
k,a,b = map(int,input().split())
bis = 1
cnt = 0
if 1+k<a or b-a<=1:
    bis = 1+k
elif (k-(a-1))%2==0:
    bis = (b+(b-a)*((k-(a-1))//2-1))
else:
    bis = (a-1)+(b+(b-a)*((k-(a-1))//2-1))
print(bis)

Submission status: Wrong Answer

Solution code:
n,A,B=map(int,input().split())

bis=1
en=0

if A+2>=B:
  ans=bis+n
else:
  if (n+1)>=(A+2):
    en+=(n+1)//(A+2)
    n-=en*(A+2)-1
    #交換
    bis=en*B
    en=0
  if n==0:
    ans=bis
  else:
    ans=bis+n
print(ans)

Submission status: Wrong Answer

Solution code:
k,a,b=map(int,input().split())
if b-a>1:
  k=k-a-1
  print((b + int(k/2)*(b-a) + k%2))
else:
  print(1+k)

Submission status: Wrong Answer

Solution code:
k,a,b=map(int,input().split())
k+=1
if(a+1>b):
  print(k)
elif(k%(a+1)==0):
  print(k//(a+1)*b+k%(a+1))
else:
  print(k//(a+1)*b+k%(a+1)-1)

Submission status: Wrong Answer

Solution code:
def read():
    return int(input())

def reads():
    return list(map(int, input().split()))

k,a,b=reads()
k2 = 0
if (b-a)/2 <= 1:
    print(1+k)
else:
    k2 = k-a+1
    if k2 >= 2:
        if k2 % 2 == 0:
            print(int(a + (b-a)*k2/2)+3)
        else:
            print(int(a + (b-a)*(k2-1)/2 + 1))
    else:
        print(1 + k)

Submission status: Wrong Answer

Solution code:
k,a,b = map(int,input().split())
if a+2 >=b:
    print(k+1)
else:
    if (k-a+1) % 2 == 0:
        print(str(((k-a+1)/2)*(b-a) + a ))
    else:
        print(str((k-a)/2*(b-a) + a +1))

Submission status: Wrong Answer

Solution code:
K,A,B=map(int,input().split())


ans=1+K
count=0
count=K//(A+2)

ANS=1+(K-2*count)+B*count-A*count


print(max(ANS,ans))

Submission status: Wrong Answer

Solution code:
k, a, b = [int(i) for i in input().split()]


sum = 0
if a >= b:
    # A >= Bの場合
    sum = k + 1
else:
    # A < B の場合
    diff = b - a
    if diff == 1:
        sum = k + 1
    elif diff == 2:
        sum = k + 1
    else:
        # a->bコンボが利潤を生み続けるパターン
        print("a")
        k = 1 + k - a
        if k % 2 == 0:
            sum = a + ((diff) * (k / 2))
        else:
            # 最後1回はコンボができないので、叩くパターン
            print("b")
            sum = a + ((diff) * ((k - 1) / 2)) + 1

print(sum)

Submission status: Wrong Answer

Solution code:
k,a,b = map(int,input().split())
bis = 1
cnt = 0
# print((a-1)+(b+(b-a)*((k-(a-1))//2-1)))
if 1+k<a or b-a==1:
    bis = 1+k
elif (k-(a-1))%2==0:
    bis = (b+(b-a)*((k-(a-1))//2-1))
else:
    bis = (a-1)+(b+(b-a)*((k-(a-1))//2-1))
print(bis)

Submission status: Wrong Answer

Solution code:
i = input().split()
k = int(i[0])
a = int(i[1])
b = int(i[2])

biscuits = 1
coin = 0

is_profitable = (b / a) > 2

if is_profitable:
    for i in range(k):
        if coin > 0:
            coin -= 1
            biscuits += b
        else:
            if biscuits >= a and i + 1 < k:
                coin += 1
                biscuits -= a
            else:
                biscuits += 1
else:
    biscuits += k

print(biscuits)

Submission status: Wrong Answer

Solution code:
K,A,B = map(int,input().split())

ans = 0
if A+1 >= B or K >= B or K < A:
    ans = K + 1
else:
    tmp = K - A

    if tmp%2 == 1:
        I = tmp+1
        I //= 2
        ans = I *B - (I-1)*A
    else:
        I = tmp
        I //= 2
        ans = 1 + I*B - (I-1)*A

print(ans)

Submission status: Wrong Answer

Solution code:
k, a, b = map(int, input().split())

def main(k, a, b):
    if k + 1 < a + 1:
        return k + 1

    dif = b - a
    


    if b > a + 2:
        if k + 1 == a + 2:
            return (k//(a + 2) - 1) * b + k % (a + 2) + b + 1
        else:
            return k//(a + 2) * b + k % (a + 2) + 1
    
    else:
        return k + 1


print(main(k, a, b))

Submission status: Wrong Answer

Solution code:
K, A, B = map(float, input().split())

K = K - (A - 1)
if (B-A) > 2:
	if K % 2 == 0:
		print(int((K/2)*(B-A)+A))
	else:
		print(int(((K - 1)/2)*(B-A) + 1 + A))
else:
	print(int(A + K))

Submission status: Wrong Answer

Solution code:
K, A, B = map(int, input().split())

if not B - A <= 2:
    if not (A == K or A == K + 1):
        if (K - A) // 2 == 0:
            print(B + (B - A) * ((K - A - 1) // 2) + 1)
        else:
            print(B + (B - A) * ((K - A - 1) // 2))
    else:
        print(K + 1)

else:
    print(K + 1)

Submission status: Wrong Answer

Solution code:
k,a,b = map(int, input().split())

bis_count = 0
k += 1
min_exchange_count = a+1+1
while True:
    if k < min_exchange_count or b <= min_exchange_count:
        bis_count += k
        break

    bis_count += b
    k -= min_exchange_count

print(bis_count)

Submission status: Wrong Answer

Solution code:
k,a,b=map(int,input().split())

f=a-1+1+1
s=a+1+1

d=(k-f)//s
m=(k-f)%s

print(b*(d+1)+m)

Submission status: Wrong Answer

Solution code:
k, a, b = map(int, input().split())
biscuit = 1
yen = 0
if b <= a or k < a or (b - a) / 2 < 1:
    print(k + 1)
    exit()
else:
    biscuit += (a - 1)
    k -= (a - 1)

print((b - a) * (k // 2) + biscuit)

Submission status: Wrong Answer

Solution code:
k,a,b=map(int,input().split())
bisk=1
if a<b:
    if a+2>k:
        bisk+=k//(a+2)*b
        for s in range(k%(a+2)):
            bisk+=1
        print(bisk+1)
    else:
        bisk+=k//(a+2)*b
        for s in range(k%(a+2)):
            bisk+=1
        print(bisk)
        
else:
    print(bisk+k)