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:
k, a, b = map(int, input().split())

if a + 2 >= b:
    cookie = k + 1 
else:
    action = int((k-(a-1))/2)
    cookie = b
    if action > 1:
        cookie += (action-1)*(b-a)
    if ((k-(a-1))/2) - action > 0:
        cookie += 1

Submission status: Wrong Answer

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

if b - a < 2 or a > k - 2:
    print(k)
else:
    # get init
    num = a
    c = k - a

    if c % 2 != 0:
        c -= 1
        num += 1

    num += c/2*(b-a)

    print(num)

Submission status: Wrong Answer

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

if b-a < 2 or a > k - 2:
    print(k)
else:
    # get init
    num = a 
    c = k - a
    
    if c % 2 != 0:
        c -= 1
        num += 1
    
    while c > 0:
        c -= 2
        num += b - a
        
    print(num)

Submission status: Wrong Answer

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

money = 0
cookie = 0
move = k

if a + 2 < b:
    action = int((k-(a-1))/2)
    cookie += b
    if action > 1:
        cookie += (action-1)*(b-a)
    if ((k-(a-1))/2) - action > 0:
        cookie += 1
else:
    cookie = k + 1


print('{}'.format(cookie))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
K,A,B = map(int, input().split())
rest = K- (A-1)
b = A + (B-1)*rest//2 + rest%2
print(max(K+1, b))

Submission status: Wrong Answer

Solution code:
# 03
# ほぼクッキークリッカー
k, a, b = map(int, input().split())

money = 0
cookie = 1
move = k

if a + 1 < b:
    cookie += b
    if int((k-(a-1))/2) > 1:
        cookie += (int((k-a)/2)*(b-a))
    if ((k-a)/2) - int((k-a)/2) > 0:
        cookie -= 1
else:
    cookie += k

print('{}'.format(cookie))

Submission status: Wrong Answer

Solution code:
def input_space():
    return list(map(int,input().split(" ")))

K,A,B=input_space()

if B-A<=2:
    res=K+1
else:
    c=B/A
    k=c-1
    t=(K-A+1)//2
    mod=(K-A+1)%2

    res=A+t*k*A

print(res)

Submission status: Wrong Answer

Solution code:
def input_space():
    return list(map(int,input().split(" ")))

K,A,B=input_space()

if B-A<=2:
    res=K+1
else:
    c=B/A
    k=c-1
    t=(K-A+1)//2
    mod=(K-A+1)%2

    res=A+t*k*A+mod

print(res)

Submission status: Wrong Answer

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

if(B-A<=2):
    bi+=K
else:
    bi+=A-1
    #print(bi)
    K1=K-(A-1)-1
    #print(K-(A-1))
    bi+=((K1)//2)*(B-A)
    #print(((K1)//2)*(B-A))
    bi+=(K1-((K1)//2))
    #print(K1-((K1)//2))
print(bi)

Submission status: Wrong Answer

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


ans=1+K
count=0
count=(K-(A+1))//2
e=(K-(A+1))%2
ANS=e+(B-A)*count

print(max(ANS,ans))

Submission status: Wrong Answer

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

def f(k,a,b):
    bsk = 1
    if (a+1)>=b or (k<(a+1)):
        bsk += k
        print(bsk)
        return
    else:
        k -= (a-1)
        bsk = a

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

    else:
        bsk +=k
    
    print(int(bsk))
    
    
f(k,a,b)

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(max(c, k))

    y = (k - (a - 1)) // 2

    # 2,3 を y回繰り返す
    # y * (b-a)まい増える

    # q = (y * (b - a) + (k - ((a - 1) + 2 * y)))
    # print(max((q + a), k + 1))

    # q = y * (b - a) + (k - 2 * y + 1)
    # print(max(q, k + 1))

    c1 = y * (b - a) + a
    if (k - (a - 1)) % 2 == 0:
        print(c1)
    else:
        print(c1 + 1)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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


ans=1+K
count=0
count=K//(A+2)
print(count)
ANS=1+(K-2*count)+(B-A)*count

print(ANS)
print(max(ANS,ans))

Submission status: Wrong Answer

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


cnt = 1

if K < A + 1:
    cnt += K
    print(cnt)
    exit()

rest = K - (A - 1)
cnt += (A - 1)

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

print(int(cnt))

Submission status: Wrong Answer

Solution code:
x, y, z= [int(i) for i in input().split()]

bis = 1

if bis < y:
    time = y-bis
    x -= time
    bis += time

#print(x,bis)

if bis >= y and z/y >2 and x >=2:
    time = int(x/2)
    x -= time*2
    bis += time*(z-y)

#print(x,bis)

if x != 0:
    bis += x

print(bis)

Submission status: Wrong Answer

Solution code:
if __name__ == "__main__":
    K,A,B = map(int,input().split())
    
    if B - A <= 2:
        print(K + 1)
    else :
        if K <= A - 1:
            print (1 + K)
        else:
            K -= A - 1
            if K % 2 == 0:
                print (int(A + (K / 2) * (B - A)))
            else:
                print (int(A + ((K - 1) / 2) * (B - 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-A)*count

print(max(ANS,ans))

Submission status: Wrong Answer

Solution code:
x, y, z= [int(i) for i in input().split()]

bis = 1

if bis < y:
    time = y-bis
    x -= time
    bis += time

#print(x,bis)

if bis >= y and z/y >2 and x >=2:
    time = int(x/2)
    x -= time*2
    bis += time*(z-y)

#print(x,bis)

if x >0:
    bis += x

if (x<0):
    bis -= x
    
print(bis)

Submission status: Wrong Answer

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


ans=1+K
count=0
count=(K-(A-1))//2
ANS=(K-2*count)+abs(A-B)*count

print(max(ANS,ans))

Submission status: Wrong Answer

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


if A > K+1 or A >= B:
  print(K+1)
else:

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

Submission status: Wrong Answer

Solution code:
# coding:utf-8

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

def cal(K, A, B):
    BNUM = 1
    TRANS_GET = B - A
    # 操作開始
    counter = 0
    while counter < K:
        nokori = K - counter
        if BNUM >= A:
        # 交換可能
            if nokori >= 2:
                syou = int(nokori / 2)
                BNUM += TRANS_GET * syou
                counter += syou * 2
            else:
                BNUM += nokori
                break
        else:
        # 交換不可
            atonanko = A - BNUM
            if atonanko < nokori-2:
                BNUM += atonanko
                counter += atonanko
            else:
                BNUM += nokori
                break
    return BNUM


if B - A <= 2:
    max_b = 1 + K
else:
    max_b = cal(K, A, B)

print(max_b)

Submission status: Wrong Answer

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

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

print(res)

Submission status: Wrong Answer

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

bis = 1

if B - A > 1:
    if K >= A + 2:
        # bis = (K - (A - 1)) // 2 * (B - A) + A
        koukan = (K - (A - 1)) // 2
        koukan_turn = koukan * 2
        nokori_turn = K - koukan_turn
        bis += koukan * (B - A) + nokori_turn
    else:
        bis += K
else:
    bis += K
    
print(bis)

Submission status: Wrong Answer

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

bis = 1

if B - A > 1:
    if K >= A + 2:
        # bis = (K - (A - 1)) // 2 * (B - A) + A
        koukan = (K - (A - 1)) // 2
        koukan_turn = koukan * 2
        nokori_turn = K - koukan_turn
        bis += koukan * (B - A) + nokori_turn
else:
    bis += K
    
print(bis)

Submission status: Wrong Answer

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

if a < b - 2:
    # k が a+2より大きい場合
    if k > (a + 1):
        # まずa+2 -1 回叩いて b 枚を得る 最初に１枚あることを考慮する
        k = k - (a - 1)
        res = b
        # 残りの k2回を a枚を1円に，1円をB枚に交換の2回の操作をできるだけ繰り返す
        # 2回の操作で (b-a)円増える
        # この操作は　k2//2 + 1 回行える
        res += (k//2) * (b - a) + (k // 2)

    # kがa+2より小さい場合は全部叩くしかない
    else:
        res = k + 1
else:
    # a枚をb枚に交換しても増えなければ全部叩いた方が良い
    res = k + 1

print(res)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if a < b - 2:
    # k が a+2より大きい場合
    if k > (a - 1):
        # まずa+2 -1 回叩いて b 枚を得る 最初に１枚あることを考慮する
        k2 = k - (a + 1)
        res = b
        # 残りの k2回を a枚を1円に，1円をB枚に交換の2回の操作をできるだけ繰り返す
        # 2回の操作で (b-a)円増える
        # この操作は　k2//2 + 1 回行える
        res += (k2//2) * (b - a) + (k2 // 2)

    # kがa+2より小さい場合は全部叩くしかない
    else:
        res = k + 1
else:
    # a枚をb枚に交換しても増えなければ全部叩いた方が良い
    res = k + 1

print(res)

Submission status: Wrong Answer

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

def uru(t, bis): # すぐ売れるとき
    c = min(t, int(bis/a)*2) # 売り買いの回数
    return int(c/2)*2, bis + (b - a)*int(c/2)

def sousa(t, bis): # 残りターン数、所持ビスケット数、所持金はゼロまで全部買った後
    req = max(a - bis, 0) + 2 # 売買に必要なターン数
    # print(t, bis, req)
    if t< req: # 残りターン不足
        print(bis + t)
        return 
    elif req >= b - a: # 売買の成果が叩く成果以下なら売買する意味なし
        print(bis + t)
        return
    elif bis > a: # すぐ売れるとき
        sousa(t - uru(t, bis)[0], uru(t, bis)[1])
    else: # 売買する
        sousa(t - req, bis + ((req - 2) - a + b)) # 売買の結果
import sys
sys.setrecursionlimit(5000000)
sousa(k, 1)

Submission status: Wrong Answer

Solution code:
K,A,B = list(map(int,input().split()))
if A>=B-1:
    answer = K+1
else:
  # gutyoku
    first = A
    rest = K - A -1
    if rest%2==0:
        answer = (rest/2+1)*B - (rest/2)*A
    else:
        #print('else')
        answer = ((rest-1)/2+1)*B - ((rest-1)/2)*A+1
        answer = -1
print(int(answer))

Submission status: Wrong Answer

Solution code:
K,A,B = list(map(int,input().split()))
if A>=B-1:
    answer = K+1
else:
  # gutyoku
    first = A
    rest = K - A -1
    if rest%2==0:
        
        answer = (rest/2+1)*B - (rest/2)*A
        answer=-1
    else:
        #print('else')
        answer = ((rest-1)/2+1)*B - ((rest-1)/2)*A+1
    
print(int(answer))

Submission status: Wrong Answer

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

if a < b - 2:
    # k が a+2より大きい場合
    if k > (a + 1):
        # まずa+2 -1 回叩いて b 枚を得る 最初に１枚あることを考慮する
        k2 = k - (a + 1)
        res = b
        # 残りの k2回を a枚を1円に，1円をB枚に交換の2回の操作をできるだけ繰り返す
        # 2回の操作で (b-a)円増える
        # この操作は　k2//2 + 1 回行える
        res += (k2//2) * (b - a) + (k2 // 2)

    # kがa+2より小さい場合は全部叩くしかない
    else:
        res = k + 1
else:
    # a枚をb枚に交換しても増えなければ全部叩いた方が良い
    res = k + 1

print(res)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if a < b - 2:
    # k が a+2より大きい場合
    if k > (a + 2):
        # まずa+2 -1 回叩いて b 枚を得る 最初に１枚あることを考慮する
        k2 = k - (a + 1)
        res = b
        # 残りの k2回を a枚を1円に，1円をB枚に交換の2回の操作をできるだけ繰り返す
        # 2回の操作で (b-a)円増える
        # この操作は　k2//2 + 1 回行える
        res += (k2//2) * (b - a)
        if k2 // 2 == 1:
            res += 1

    # kがa+2より小さい場合は全部叩くしかない
    else:
        res = k + 1
else:
    # a枚をb枚に交換しても増えなければ全部叩いた方が良い
    res = k + 1

print(res)

Submission status: Wrong Answer

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

bis = 1

if 1+k<a or abs(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:
K,A,B = list(map(int,input().split()))
if A>=B-1:
    answer = K+1
if A > K-1:
    answer = K+1
else:
  # gutyoku
    first = A
    rest = K - A -1
    if rest%2==0:
        answer = (rest/2+1)*B - (rest/2)*A
    else:
        print('else')
        answer = ((rest-1)/2+1)*B - ((rest-1)/2)*A+1
    
print(int(answer))

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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


def uru(t, bis):
    c = min(t, int(bis/a)*2) # 売る回数=買う回数
    return int(c/2)*2, bis + (b - a)*int(c/2)

def sousa(t, bis): # 残りターン数、所持ビスケット数、所持金はゼロまで全部買った後
    req = max(a - bis, 0) + 2 # 売買に必要なターン数
    # print(t, bis, req)
    if t< req: # 残りターン不足
        print(bis + t)
        return 
    elif req >= b - a: # 売買の成果が叩く成果以下なら売買する意味なし
        print(bis + t)
        return bis + t
    elif bis > a: # 売るのみ
        sousa(t - uru(t, bis)[0], uru(t, bis)[1])
    else: # 売買する
        sousa(t - req, bis + ((req - 2) - a + b)) # 売買の結果

import sys
sys.setrecursionlimit(5000000)
sousa(k, 1)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
S, A, B = map(int,input().split())
K = S
bis = 0
while K > 0:
  K -= A
  bis //= A
  bis += B*max(bis//A,1)
print(bis-1)

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:
# 2019/02/09
# Minnano Procon 2019 - C

# Input
k, a, b = map(int,input().split())
bispos = 1

# Exchange biscuit
if a < b:
    if k < (a - 2) or (b - a) <= 1:
        bispos += k-2
        bispos = int(bispos/a) * b + bispos % a
    else:
        w_acmcnt = (k - (a - 1)) / 2
        remine_b = 0
        if w_acmcnt % 1 != 0:
            w_acmcnt = int(w_acmcnt)
            remine_b = 1
        bispos = remine_b
        bispos += (b - a) * w_acmcnt + a

else:
    bispos += k

# Output
print("{:.0f}".format(bispos))

Submission status: Wrong Answer

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

if a < b - 2:
    # k が a+2より大きい場合
    if k > (a + 2):
        # まずa+2回叩いて b 枚を得る
        k2 = k - (a + 2)
        res = b
        # 残りの k2回を a枚を1円に，1円をB枚に交換の2回の操作をできるだけ繰り返す
        # 2回の操作で (b-a)円増える
        # この操作は　k2//2 + 1 回行える
        res += (k2//2 + 1) * (b - a)
        if k2 // 2 == 1:
            res += 1

    # kがa+2より小さい場合は全部叩くしかない
    else:
        res = k + 1
else:
    # a枚をb枚に交換しても増えなければ全部叩いた方が良い
    res = k + 1

print(res)

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
print(d)

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

Submission status: Wrong Answer

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


ans=1+K
count=0
count=(K-(A-1))//2
ANS=1+(K-2*count)+abs(A-B)*count

print(max(ANS,ans))

Submission status: Wrong Answer

Solution code:
k, a, b=map(int, input().split())
index=0
coockie=1
index=0
flag=0
if b-a <= 2:
    print(k+1)
else:
    while index < k:
        if coockie < a:
            if index+(a-coockie) < k:
                plus = (a-coockie)
                coockie += plus
                index += plus
            else:
                coockie+=(k-index)
                index+=(k-index)
        else:
            if index < k-2:
                coockie-=a
                coockie+=b
                index+=2
            else:
                coockie+=1
                index+=1
        if coockie > a:
            flag=1
            break
    if flag==0:
        print(coockie+(k-index))
    else:
        if index < k-2:
            if (k-index)%2==0:
                print(coockie+((k-index)//2)*(b-a))
            else:
                print(coockie + ((k-index)//2)*(b-a) + (k-index)%2)
        else:
            print(coockie+(k-index))

Submission status: Wrong Answer

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

count = 0
bis = 1
yen = 0

# 制約条件
if 1 <= kab[0] <= 10**9 and 1 <= kab[1] <= 10**9 and 1 <= kab[2] <= 10**9:
    while count < kab[0]:
        if kab[1] < kab[2]:
            if yen > 0:
                bis += kab[2]
                yen = yen - 1
                count += 1
            elif bis < kab[1]:
                bis += 1
                count += 1
            else:
                 bis = bis - kab[1]
                 yen = 1
                 count += 1
            
        else:
            bis += 1
            count += 1
    print(bis)

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
print(d)

if A+1>=B :
    x=1+K
    print(x)
elif A>=K:
    print(K+1)
elif d%2==0:
    if K==A+2:
        print(B+1)
    else:
        x1=int(((d-2)*(B-A)*(1/2))+B)
        x1=x1+1
        print(int(x1))
elif d%2==1:
    if K==A+1:
        print(B)
    else:
        x2=int(((d-1)*(B-A)*(1/2))+B)
        print(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  = A
  k = K - i
  bis += (k//2)*(B-A)
  bis += k %2
print(bis)

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 - 2 or B - A < 3 :
    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:
from sys import stdin
K,A,B=[int(x) for x in stdin.readline().rstrip().split()]

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

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+4>b):
    print(1+k+(int((1+k)/(2*a-b+4)))*(b-a-2))
else:
    print(1+k+(int((1+k-a)/2))*(b-a-2))

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

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

def main():
    bisk_num = 1
    yen = 0
    for k in range(K):
        if (k == K - 2):
            bisk_num += 1
        elif (yen > 0):
            yen -= 1
            bisk_num += B
        elif ((bisk_num >= A )and (B > K - k + A)):
            yen += 1
            bisk_num -= A
        else:
            bisk_num += 1
    print(bisk_num)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

N = []

for n in range(1, (k+1)//a+1):
    x = n*a - 1
    #y = int(log((b/a-1)*k+1, b/a))
    #z = y
    #m = 1 + x - a*y + b*z
    #y = y+1
    #z= z+1
    #mm = 1 + x - a*y + b*z
    #mmm = [m, mm]
    #N.append(max(mmm))
    y = (k - x)//2
    z = y
    N.append(1 + x - a*y + b*z)
N.append(k+1)
print(max(N))

Submission status: Wrong Answer

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

if a < b - 2:
    # k が a+2より大きい場合
    if k > (a + 2):
        # まずa+2回叩いて b 枚を得る
        k2 = k - (a + 2)
        res = b
        # 残りの k2回を a枚を1円に，1円をB枚に交換の2回の操作をできるだけ繰り返す
        # 2回の操作で (b-a)円増える
        # この操作は　k2//2 + 1 回行える
        res += (k2//2 + 1) * (b - a)
        if k2 // 2 == 0:
            res -= 1

    # kがa+2より小さい場合は全部叩くしかない
    else:
        res = k + 1
else:
    # a枚をb枚に交換しても増えなければ全部叩いた方が良い
    res = k + 1

print(res)

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
print(d)

if A+1>=B :
    x=1+K
    print(x)
elif A>=K:
    print(K+1)
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=int(((d-1)*(B-A)*(1/2))+B)
        x2=x2+3
        print(x2)

Submission status: Wrong Answer

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

def f(k,a,b):
    bsk = 1
    if (a+1)>=b or (k<(a+1)):
        bsk += k
        print(int(bsk))
        return
    else:
        k -= (a-1)
        bsk = a

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

        else:
            bsk +=k
    
    print(int(bsk))
    
    
f(k,a,b)

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 < 3 or B < 3:
    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())


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

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


print(max(ANS,ans))

Submission status: Wrong Answer

Solution code:
k, a, b=map(int, input().split())
index=0
coockie=1
index=0
flag=0
if b-a <= 2:
    print(k+1)
else:
    while index < k:
        if coockie < a:
            if index+(a-coockie) < k:
                plus = (a-coockie)
                coockie += plus
                index += plus
            else:
                coockie+=(k-index-1)
                index+=(k-index-1)
        else:
            if index < k-2:
                coockie-=a
                coockie+=b
                index+=2
            else:
                coockie+=1
                index+=1
        if coockie > a:
            flag=1
            break
    if flag==0:
        print(coockie+(k-index))
    else:
        if index < k-2:
            if (k-index)%2==0:
                print(coockie+((k-index)//2)*(b-a))
            else:
                print(coockie + ((k-index)//2)*(b-a) + (k-index)%2)
        else:
            print(coockie+(k-index))

Submission status: Wrong Answer

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

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

bis = 1
coin = 0

for i in range(k):
    #if coin == 1 and k-i !=2:
    if i == k-1:
        bis = bis + b*coin
        coin = 0
        #print('a '+str(bis)+' '+str(coin))
    elif  bis >= a:
        bis = bis - a
        coin = 1
        #print('b '+str(bis)+' '+str(coin))
    elif bis < a:
        bis = bis +1
        #print('c '+str(bis)+' '+str(coin))

print(bis)

Submission status: Wrong Answer

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

if a < b - 2:
    # k が a+2より大きい場合
    if k > (a + 2):
        # まずa+2回叩いて b 枚を得る
        k2 = k - (a + 2)
        res = b
        # 残りの k2回を a枚を1円に，1円をB枚に交換の2回の操作をできるだけ繰り返す
        # 2回の操作で (b-a)円増える
        # この操作は　k2//2 + 1 回行える
        res += (k2//2 + 1) * (b - a)

    # kがa+2より小さい場合は全部叩くしかない
    else:
        res = k + 1
else:
    # a枚をb枚に交換しても増えなければ全部叩いた方が良い
    res = k + 1

print(res)

Submission status: Wrong Answer

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


ans=1+K
count=0
count=(K-(A-1))//2
print(count)
ANS=1+(K-2*count)+abs(A-B)*count

print(ANS)
print(max(ANS,ans))

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 a == 1:
    if k%2==0:
        bis = b*(k//2)-1
    else:
        bis = b*(k//2)
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:
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 K > 1 and K >= A:
  if change == 0:
    bis +=K
  else:
    i = A - 1
    bis  = A
    k = K - i
    bis += (k//2)*(B-A)
    bis += k %2
elif K == 1:
  bis == 2
else:
  bis +=K
print(bis)

Submission status: Wrong Answer

Solution code:
x, y, z= [int(i) for i in input().split()]

bis = 1

if bis < y:
    time = y-bis
    x -= time
    bis += time

#print(x,bis)

if bis >= y and z/y >2 and x >=2:
    time = int(x/2)
    x -= time*2
    bis += time*(z-y)

#print(x,bis)

if x >0:
    bis += x

print(bis)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

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

def main():
    bisk_num = 1
    yen = 0
    for k in range(K):
        if (yen > 0):
            yen -= 1
            bisk_num += B
        elif ((bisk_num >= A )and (B > K - k + A) and (k < K - 1)):
            yen += 1
            bisk_num -= A
        else:
            bisk_num += 1
    print(bisk_num)

if __name__ == "__main__":
    main()

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 and a==1:
    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:
if __name__ == "__main__":
    K,A,B = map(int,input().split())
    
    if A > B:
        print(1 + K)
    elif B - A == 1:
        print(1 + K)
    else :
        if K < A - 1:
            print (1 + K)
        else:
            K -= A - 1
            if K % 2 == 0:
                print (int(A + (K / 2) * (B - A)))
            else:
                print (int(A + ((K - 1) / 2) * (B - A) + 1))

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 + 2 or B - A < 3 :
    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:
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 K > 1 and K >= A:
  if change == 0:
    bis +=K
  else:
    i = A - 1
    bis  = A
    k = K - i
    bis += (k//2)*(B-A)
    bis += k %2
elif K == 1:
  pass
else:
  bis +=K
print(bis)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# 03
# ほぼクッキークリッカー
k, a, b = map(int, input().split())

money = 0
cookie = 1
move = k

if a + 1 < b:
    cookie += b
    if int((k-a)/2) > 1:
        cookie += (int((k-a)/2)*(b-a))
    if ((k-a)/2) - int((k-a)/2) > 0:
        cookie -= 1
else:
    cookie += k

print('{}'.format(cookie))

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 < 3 :
    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:
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 K > 1 and K-A > 2:
  if change == 0:
    bis +=K
  else:
    i = A - 1
    bis  = A
    k = K - i
    bis += (k//2)*(B-A)
    bis += k %2
elif K == 1:
  pass
else:
  bis +=K
print(bis)

Submission status: Wrong Answer

Solution code:
K, A, B = input().split()
k=int(K)
a=int(A)
if k%a==0:
    m=k/a-1
else:
    m=int(k/a)
if k-m*a==1:
    print(m*int(B))
else:
    print(int(m*int(B)+k-m*a-1))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
from collections import defaultdict
K, A, B = map(int, input().split())
ans = 1
if K == 1:
    print(ans+K)
    exit()

if B/A < 2.0:
    print(ans+K)
    exit()

if K + 1 < A:
    print(ans+K)
    exit()

x = int((K+1)/(A+2))

ans += x*B - x*A + (K-2*x) 

print(ans)