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: Accepted

Solution code:
"""
A+2 < B の場合はビスケットを換金した方が良い
ビスケットを(A-所持数)回叩く
ビスケットを1円に換金する（所持数=0)
ビスケットを1円でB枚購入する（所持数+=B）

それ以下の場合はビスケットを叩いた方が良い
ビスケットをK回叩く

換金する場合、ビスケットを叩いて増やすとは限らない


K:3, A:2, B:3
1. 叩いてビスケット2
2. 換金してビスケット0, 1円
3. 購入してビスケット3


K:3, A:2, B:3
1. 叩いてビスケット2
1. 叩いてビスケット3
1. 叩いてビスケット4

K:3, A:2, B:4
1. 叩いてビスケット2
2. 換金してビスケット0, 1円
3. 購入してビスケット4


K:3, A:2, B:5
1. 叩いてビスケット2
2. 換金してビスケット0, 1円
3. 購入してビスケット5


叩いてもAに到達できないなら交換しない (K < A-1)
レートがマイナスなら交換しない（A+2 >= B）

ビスケットをA枚にする (A-1回叩く）
換金する
購入する（B枚）
B >= A なら換金する
購入する（B枚）

"""

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

def count_cookie1():
    act = K-2
    act += 1
    cookie = act % A
    yen = act // A
    cookie += yen * B
    return cookie


def count_cookie2():
    global K, A, B
    cookie = 1
    while K > 0:
        print(K, A, cookie)
        if (K < A-cookie) or (A+2 >= B): # 叩いて終わり
            cookie += (K)
            return cookie
        elif (K >= A-cookie+2): # 換金して購入する
            if (A-cookie) > 0:
                K -= (A-cookie)
            else:
                K -= 2

            cookie -= A
            cookie += B
        else: # 叩く
            K -= (A-cookie)
            cookie += (A-cookie)
    return cookie


"""
1. K段階の数直線を定義する
2. A枚までは+1ずつ増加する
3. 以降は2ステップごとに+(B-A)ずつ増加する
    3-1. 増加数がマイナスなら処理をキャンセルして残りK枚追加する
4. 残り1ステップ以下になったら+1ずつ増加する
5. 残りステップが0になったら終了
"""
def count_cookie3():
    global K, A, B
    cookie = 1

    # 2
    if cookie < A:
        K -= (A-cookie)
        cookie = A
    # 3
    n = K // 2
    if (B-A) > 2:
        cookie += (B-A)*n
    else:
        cookie += K
        K = 0
    # 4    
    n = K % 2
    cookie += n
    return cookie


if A+2 < B:
    cookie = count_cookie3()
else:
    cookie = K+1

print(cookie)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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(bis + 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: Accepted

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)
    b += K % 2
    print(b)
else:
    b += K
    print(b)

Submission status: Accepted

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

K += 1
ans = 0

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

Submission status: Accepted

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

delta = B - A

if delta <= 2 or A >= K:
    print(K+cookie)
    exit()

# hit while able to exchange
fst_hit = A - 1
cookie += fst_hit

# exchange
exchange_count = int((K - A+1)/2)
cookie += (delta * exchange_count)

# hit
cookie += (K-fst_hit) % 2

print(cookie)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
K,A,B = [int(_) for _ in input().split()]
N = 1
Y = 0

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

Submission status: Accepted

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

Submission status: Accepted

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 and a>1 or n<3):
    print(k+1)
else:
    print(bis+add_bis + a)

Submission status: Accepted

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


bs = 1
yen = 0

if B-A > 2 and K >= (A-1):#まずA枚まで増やす
    K = K -(A - 1)
    numC = K//2#交換回数
    yen = A+(B-A) * numC + K%2
    print(yen)
else:#ひたすら割る
    print(1+K)

Submission status: Accepted

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

if B-A >= 3 and K >= A+2-1:
  bis = B
  K = K-(A+2-1)
  rem = K%2
  bis = bis + (B-A)*(K//2) + rem

else:
  bis = 1+K

print(bis)

Submission status: Accepted

Solution code:
import math
K,A,B = list(map(int, input().strip().split(' ')))
biscuit = 1
if B-A <= 2: # ひたすら叩く
  print(1+K)
  exit()
remain_act = K
while remain_act > 0:
  if biscuit < A: # 交換できない
    if remain_act >= A-biscuit+2: # 交換できるようになるまで叩く
      biscuit += A-1
      remain_act -= A-1
    else: # 最後まで叩く
      biscuit += remain_act
      remain_act = 0
  elif remain_act > 1: #A枚→1円→ビスケットB枚
    t = math.floor(remain_act/2)
    biscuit += (B-A)*t
    remain_act -= 2*t
  elif remain_act == 1:
    biscuit += 1
    break
print(biscuit)

Submission status: Accepted

Solution code:
def main():
    k, a, b = map(int, input().split())
    print(solve(k, a, b))

def solve(k, a, b):
    if b - a <= 2:
        return k + 1
    
    if (k - a + 1) % 2 == 0:
        n = (k - a + 1) // 2
        return a + (b - a) * n
    else:
        n = (k - a + 1) // 2
        return a + (b - a) * n + 1

main()

Submission status: Accepted

Solution code:
k, a, b = map(int, input().split())
first_k = k
bis = 1
if b - a >= 2:
    # 交換したほうが多い
    # 1回目
    k -= a - 1
    bis += a - 1
    change_count = k//2
    bis += change_count * (b - a)
    if bis >= 0:
        print(bis + (k % 2))
    else:
        print(first_k+1)

else:
    # たたいたほうが多い
    print(k+1)

Submission status: Accepted

Solution code:
import math

data = input().split()  

k = int(data[0])
a = int(data[1])
b = int(data[2])


bi=1


if(a+2>=b):
    bi=k+1
elif((a+2)>(k+1)):
    bi=k+1
else:
    bi+=(b-a)+(a-1)
    k-=(a+1)
    bn = math.floor(k/2)
    bb = k%2
    bi+=(bn*(b-a) + bb)

print(bi)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

if B-A <=2:
	print(K+1)
else:
	tmp = (A-1)
	tmp2 = A + diff*int((K-tmp)/2) + (K-tmp)%2
	print(int(tmp2))

Submission status: Accepted

Solution code:
K,A,B = map(int, input().split())
bis=1
nokori_kaisuu=K
if A+3<B:
    tataki_onechange_max=K-2
    if tataki_onechange_max+1>=A:
        bis+=((A-1)+(B-A))
        nokori_kaisuu-=((A-1)+2)
        more_change_kaisuu=nokori_kaisuu//2
        bis+=(B-A)*more_change_kaisuu
        nokori_kaisuu-=2*more_change_kaisuu
        if nokori_kaisuu==1:
            bis+=1
    else:
        bis+=K
else:
    bis+=K
print(bis)

Submission status: Accepted

Solution code:
K, A, B = (int(i) for i in raw_input().split(' '))

action = K
cookie = 1

if A + 3 > B:
    cookie += K
    print(cookie)
else:
    init_break_n = min(action, A - cookie)
    action += -(init_break_n)
    cookie += init_break_n
    if action > 0:
        trade_n = int(action/2)
        cookie += (B-A)*trade_n
        if action % 2 == 1:
            cookie += 1
    print(cookie)

Submission status: Accepted

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

def solve(A,B,K):
    if A>=B-1 or A-1>=K:
        return K+1
    K-=(A-1)
    if K%2==0:
        return int(A+(B-A)*int(K/2))
    else:
        return A+(B-A)*int((K-1)/2)+1

print(solve(A,B,K))

Submission status: Accepted

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
    if (K - A - 1) % 2 != 0:
        ans = B + t * (B - A) + 1
    else:
        ans = B + t * (B - A)
    print(ans)

Submission status: Accepted

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

ans = 0
if A+2 >= B or K+2 < 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: Accepted

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

ans = 1 + k
if b <= a + 2:
    print(ans)
else:
    if (k - a + 1) % 2 == 0:
        i = a - 1
    else:
        i = a
    ans = 1 + i + ((b - a) * (k - i) // 2)
    print(ans)

Submission status: Accepted

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

if (B-A) > 2:#交換すべき
    change = True
else:
    change = False

can = False
while(True):
    if change:
        if can:#交換可能
            multi = K//2
            K -= 2*multi
            ans += (B-A)*multi
            ans += K
            break
        else:
            if ans >= A:
                if (K-2) >= 0:
                    ans -= A
                    ans += B
                    K -= 2
                    can = True
                else:
                    ans += K
                    K -= K
                    break
            else:
                if ans + (K-2) >= A:
                    K -= (A-ans)
                    ans = B
                    K -= 2
                else:
                    ans += K
                    K -= K
                    break                
    else:
        ans += K
        K -= K
        break

print(ans)

Submission status: Accepted

Solution code:
import math
K, A, B = map(int, input().split())
ans = K+1
if B > 2 + A:
  N = K - A
  if N == 1:
    ans = B
  elif N%2==1:
    ans=B+(B-A)*math.floor((K-A)/2)
  elif N%2==0:
    ans=B+(B-A)*math.floor((K-A)/2-1)+1

print(ans)

Submission status: Accepted

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


if B<=A+2:
	print 1+K
else:
	ans=0

	K-=(A-1)
	ans+=A
	
	t=K/2
	K-=t*2
	ans+=(B-A)*t

	ans+=K

	print ans

Submission status: Accepted

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

unused_turn = K
biscuit = 1

# 換金が割に合わなかったら叩くだけ
if B - A <= 1 or K < A:
    print(1 + K)
    exit()

# お金にできるまで叩く
unused_turn -= A - 1
biscuit += A - 1


# お金をやりくりする
turn = unused_turn // 2
biscuit = biscuit - turn * A + turn * B
unused_turn -= turn * 2

# 最後に叩く
biscuit += unused_turn

print(biscuit)

Submission status: Accepted

Solution code:
k,a,b=map(int,input().strip().split())
if b-a<=2:
    print(1+k)
else:
    d=b-a
    step=k-a+1
    if step%2==0:
        n=int(step/2)
        print(a+n*d)
    else:
        n=int(step/2)
        print(a+n*d+1)

Submission status: Accepted

Solution code:
k,a,b = map(int,input().split())
counter = k
x = 1
s = 0

if a >= b or (a < b and b - a <= 2) or counter < a - 1:
    x = 1+k
elif a < b and b - a > 2:
    counter -= a-1
    x += a-1
    if counter > 1 and counter % 2 == 0:
        z = int(counter/2)
        x += int((b-a)*z)
    elif counter > 1 and counter % 2 == 1:
        z = int(counter/2)
        x += int((b-a)*z + 1)
    elif counter == 1:
        x += 1


print(x)

Submission status: Accepted

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

k -= a+1
answer = b
answer += (k // 2) * (b - a)
answer += k % 2

print(answer)

Submission status: Accepted

Solution code:
In = list(map(int, input().split()))
K = In[0]
A = In[1]
B = In[2]

if A >= B:
    print(1 + K)
elif A + 1 == B:
    print(1 + K)
elif A + 2 == B:
    print(1 + K)
else:
    n = A - 1 #A枚たまるまでのパンパン回数
    if (K - n) % 2 == 0:
        print(A + (B - A) * (K - n) // 2)
    else:
        num = 1 + A + (B - A) * (K - n - 1) // 2
        print(num)

Submission status: Accepted

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

ans1 = k+1
cnt = (k-(a-1)) // 2
mod = (k-(a-1)) % 2
ans2 = cnt * (b - a) + a + mod

print(max(ans1,ans2))

Submission status: Accepted

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

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

    print(sum)

Submission status: Accepted

Solution code:
#coding:utf-8

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

if B - A <= 2:
    answer = 1 + K


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

print(answer)

Submission status: Accepted

Solution code:
K,A,B = map(int,input().split())
bisc = 1
money = 0

if B-A < 3:
  print(bisc + K)
else:
  bisc += A-1
  K -= A-1
  if K >= 2:
    change_n = int(K/2)
    bisc += change_n*(B-A)
    K -= change_n*2
  bisc += K
  print(bisc)

Submission status: Accepted

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

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

Submission status: Accepted

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

if A + 2 >= B:
    print(K + 1)
else:
    temp = (K - A + 1)
    n = temp // 2

    result = n * B - (n - 1) * A + temp % 2

    print(result)

Submission status: Accepted

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

if A >= B -1: # 差が１以下ならば、そのまま割って行くほうがコスト的に良い
    re = K + 1
else:
    ite = (K - (A - 1) ) // 2
    re = B * ite - A *(ite - 1) 
    if (K - (A - 1)) % 2 == 1:
        re += 1
print(re)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

count = 1

if B-A<=2 or A>K+1:
	count += K
	K = 0

else:
	K=K-A+1
	count=A

	count += K/2 * (B-A)
	count += K%2


print count

Submission status: Accepted

Solution code:
import math

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


if B - A <= 2 or K <= A:
    biscuit = K + 1
    
else:
    if (K - A) % 2 != 0:
        b = math.ceil((K - A) / 2)
        a = math.floor((K - A) / 2)
        biscuit = b * B - a * A
        
    else:
        b = math.ceil((K - A - 1) / 2)
        a = math.floor((K - A - 1) / 2)
        biscuit = b * B - a * A + 1
    
print(biscuit)

Submission status: Accepted

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

ans = min(A, K)
cnt = min(A - 1, K - 1)
res = K - cnt
if B - A >= 2:
    ans += (B - A) * (res // 2)
    ans += res % 2
else:
    ans += res

print(ans)

Submission status: Accepted

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

if (b-a)/2<=1:
    print(k+1)
else:
    s=k-a-1
    if s%2==0:
        print(int((s//2+1)*b-(s*a)//2))
    else:
        s1=s-1
        print(int((s1//2+1)*b-(s1*a)//2+1))

Submission status: Accepted

Solution code:
def solve(k, a, b):
    if b <= a + 2:
        return 1 + k
    # init
    c = 0
    k += 1
    # c = a ?
    if k < a + 2:
        return k
    c = 0
    k -= a + 1
    num_iter, rest = divmod(k, 2)
    if rest == 0:
        # ends (2)
        c += (num_iter - 1) * (b - a)
        c += b + 1
    else:
        c += num_iter * (b - a) + b
    return c


def main():
    k, a, b = (int(z) for z in input().split())
    res = solve(k, a, b)
    print(res)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

if b - a > 1 and a < k:
    bk = b + ((k - (a + 1)) // 2) * (b - a) + (k - (a + 1)) % 2
else:
    bk = k + 1
    
print(bk)

Submission status: Accepted

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

turns = k - (a - 1) - 2
bis = b + (turns // 2) * (b - a) + (turns % 2)

print(max(k + 1, bis))

Submission status: Accepted

Solution code:
def c_biscuit(K, A, B):
    if A >= B:
        return K + 1
    if B == A + 1:
        return K + 1
    if K <= A - 1:
        return K + 1

    count = A - 1
    now_biscuit = A

    remain_count = (K - count) // 2
    now_biscuit = now_biscuit + remain_count * (B - A)

    if ((K - count) % 2) == 1:
        now_biscuit += 1

    return now_biscuit

K, A, B = [int(i) for i in input().split()]
print(c_biscuit(K, A, B))

Submission status: Accepted

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

c = 1
multi = 0
add = 0

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

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

    K -= A + 1
    c = B
    multi = int((K - (K % 2)) / 2)
    add = (B - A) * multi
    c += add

    if K % 2 == 1:
        c += 1
    print(c)

Submission status: Accepted

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

if e <= 2 or A >= K:
    ans = K + 1
else:
    ans = B
    count = A + 1
    while count < K:
        e_count = min(ans // A, (K - count) // 2)
        if e_count > 0:
            ans += e_count * e
            count += e_count * 2
        else:
            if A > ans:
                count += min(A - ans, K - count)
                ans += min(A - ans, K - count)
            else:
                tataku = K - count
                count += tataku
                ans += tataku
print(ans)

Submission status: Accepted

Solution code:
inp = input().split()

K = int(inp[0])
A = int(inp[1])
B = int(inp[2])

count = 1

remain = K

if (B - A <= 2):
    count += remain
else:
    if (A - 1 >= remain):
        remain = 0
        count += remain
    else:
        while(True):
            remain -= A-1
            count += A-1
            if (remain == 0):
                break
            elif (remain%2== 1):
                count += remain//2*(B-A)
                count += 1
                break
            else:
                count += remain//2*(B-A)
                break


print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**8) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

    
k,a,b = li()
k += 1

if k <= a:
    print(k)

elif b <= a+2:
    print(k)

else:
    k -= a
    n = k//2
    print(b + (n-1)*(b-a) + bool(k%2))

Submission status: Accepted

Solution code:
inp  = [int(i) for i in input().split()]
k = inp[0]
a = inp[1]
b = inp[2]
k_ = (k - a + 1)//2
if b - a < 2:
    print(1 + k)
else:
    if (k - a + 1) % 2 == 0:
        print(a + (b - a) * k_)
    else:
        print(a + (b - a) * k_ + 1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
k,a,b=map(int,input().split())
count=0
if b<=a+2:
    count=k+1
else:
    if k<=a:
        count=k+1
    else:
        x=(k-(a+1))//2
        y=k-2*x-(a+1)
        count=(b-a)*x+b+y

print(count)

Submission status: Accepted

Solution code:
import math
import copy
import bisect








def nCast(number):
    if type(number)==str:
        return int(number)
    for idx in range(0,len(number)):
        if type(number[idx])==str:

            number[idx]=int(number[idx])
        else:
            nCast(number[idx])
    return number
    
def inputArr(w):
    l=list()
    for idx in range(0,w):
        l.append(input())
    return l
def inputArr1(w):
    l=list()
    for idx in range(0,w):
        l.append(input().split())
    return l

n=nCast(input().split())

def func():

    if n[2]-n[1]<2:
        return 1+n[0]
    if n[1]-1>=n[0]:
        return 1+n[0]

    result=n[1]
    ret=n[0]+1-n[1]
 
    if ret%2==0:

        
        return result+int(ret/2)*(n[2]-n[1])
    return 1+result+int((ret-1)/2)*(n[2]-n[1])

print(int(func()))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

def solve():
    K, A, B = map(int, input().split())
    res = 1
    if B <= A:
        res += K
    elif K <= A:
        res += K
    elif B-A<=2:
        res += K
    else:
        K -= (A-1)
        res += A-1
        res += (K//2)*(B-A)
        res += K%2

    return str(res)
if __name__ == '__main__':
    print(solve())

Submission status: Accepted

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

if b-a <= 2:
    print(1+k)
else:
    if k < a+1:
        print(1+k)
    else:
        p = (k-a)//2
        if (k-a-1)%2 == 0:
            print((1+p)*b-p*a)
        else:
            p -= 1
            print((1+p)*b-p*a+1)

Submission status: Accepted

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

Submission status: Accepted

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

ans = 1
cnt = 0

if A + 1 < B and K >= A+1:
    cnt += A + 1
    ans = B
else:
    print(ans + K)
    exit()

if ans >= B:
    k = int((K-cnt) / 2)
    ans += k * (B - A)
    c = int((K-cnt) % 2)
    print(ans+c)
else:
    print(ans + K)

Submission status: Accepted

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

Submission status: Accepted

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

main()

Submission status: Accepted

Solution code:
import sys


a = list(map(int, input().split()))
K, A, B = a[0], a[1], a[2]

bis = 1
money = 0
sub_K = A + 2 # adを得るまでの動作回数
# 初期状態
ad = B - A
if ad <= 2 or K < sub_K - 1:
  print(1+K)
  sys.exit()

else:
  bis = B
  K -= sub_K - 1

exchange = 2 # 錬金するのに必要な回数

mult = K // exchange
bis += ad * mult

remain = K % exchange
bis += remain

print(bis)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

def parse(inp):
    K,A,B=map(int,next(inp).split())
    return K,A,B
  
def main(inp):
    K,A,B=parse(inp)
    
    if(B-A <= 2):
        return K+1
    
    else:
#        print(K)
        K=K-A+1
        bis=A+int(K/2)*(B-A)
#        print(bis)
        
        if(K%2==0):
            return bis
        else: return bis+1
        
print(main(sys.stdin))

Submission status: Accepted

Solution code:
a=input().split()
b=int(a[0])
c=int(a[1])
d=int(a[2])
x=0
y=0
if d-c<=2:
    x+=b+1
else:
    if b<=min(c,d) :
        x+=b+1
    else:
        x+=c+abs(d-c)*((b-min(c,d)+1)//2)+(b-(min(c,d)-1))%2
print(x)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
k,a,b=map(int,input().split())
n=1
if b-a<=2:
    n += k
    print(n)

elif k<a-1:
    n += k
    print(n)

else: #b-a>2 k-(a-1)>=0
    #1、n,1からa
    n = a
    k -= a-1  #>0
    m = k // 2
    n += (b-a)*m
    if k - 2*m ==1:
        n+=1
    print(n)

Submission status: Accepted

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

#A >= Bか換金->交換の利得が少ないときはビスケットを叩き続ける
if A >= B - 2:
    print(K + 1)
else:
    #A<Bの時はビスケットをA枚まで貯めた後換金と交換を繰り返す
    n = int((K - (A - 1)) / 2)
    print(n*(B-A-2) + K + 1)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
K, A, B = map(int, input().split())

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

n = A - 1
print(1 + n + (K - n) // 2 * (B - A) + (K - n) % 2)

#  def f(n):
#      return (1 + n) // A <= (K - n) // 2
#
#
#  ok = 0
#  ng = int(10**9 + 1)
#  while ng - ok > 1:
#      m = (ok + ng) // 2
#      if f(m):
#          ok = m
#      else:
#          ng = m
#
#  print(1 + ok + (B - A) * ((1 + ok) // A))

Submission status: Accepted

Solution code:
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [K, A, B] = [long(input_raw[0]), long(input_raw[1]), long(input_raw[2])]

    K_ = K - (A - 1)
    print max((B - A) * (K_/2) + A + K_% 2, K + 1)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

if b - a < 2:
    print(1+k)
else:
    c = a - 1 + 2
    d = k - c
    if d % 2 == 0:
        print((d//2)*(b-a)+b)
    else:
        print((d//2)*(b-a)+b+1)

Submission status: Accepted

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

if B - A <= 1:
    print(K + 1)
else:
    bisket_sum = A
    k_remained = K - A + 1
    bisket_sum += (k_remained // 2) * (B - A)
    bisket_sum += k_remained % 2
    print(bisket_sum)

Submission status: Accepted

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

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

cnt = (K - (A - 1)) // 2
ans = A
ans += (B - A) * cnt
ans += (K - (A - 1)) % 2

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
K, A, B = map(int, input().split())
count = 0
if(A >= B-2):
    # print(K+1)
    count = K+1
else:
    K = K - (A - 1)

    if(K%2==0):
        count += ((K//2)-1)*(B-A) + B
    else:
        count+=(K//2-1)*(B-A) + B
        count+=1
        # print("No")

print(count)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
k,a,b = ([int(i) for i in input().split()])
ans = 1
if 2 >= (b-a):
    ans = ans + k
else:
    n = k - (a-1)
    ans = ans + (a-1)
    if n %2 == 0:
        ans = ans + n//2 * (b-a)
    else:
        ans = ans + n//2 * (b-a) + 1
print(ans)

Submission status: Accepted

Solution code:
K, A, B = map(int,input().split())
if A+1 >= B:
    print(K+1)
elif A >= K:
    print(K+1)
else:
    # biscuit = 1
    # Yen = 0
    # for i in range(0,K):
    #     if biscuit >= A and i != K-1:
    #         biscuit -= A
    #         Yen += 1
    #     elif Yen >= 1:
    #         biscuit += B
    #         Yen -= 1
    #     else:
    #         biscuit += 1
    #     print(biscuit, Yen)
    # print(biscuit)
    # 遅すぎる
    K -= A-1
    biscuit = A
    if K % 2 == 0:
        excnt = int(K/2)
        biscuit += excnt * (B-A)
    else:
        excnt = int(K/2)
        biscuit += excnt * (B-A)+1
    print(biscuit)

Submission status: Accepted

Solution code:
K,A,B = map(int,input().split())
if A+2 >= B:
	print(1+K)
elif K <= A:
	print(1+K)
else:
	new_K = K-A
	if new_K % 2 == 1:
		temp_K = int((new_K+1)/2)
		print((temp_K*B - (temp_K-1)*A))
	else:
		temp_K = int(new_K/2)
		print((int(temp_K*B - (temp_K-1)*A + 1)))