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:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
k,a,b = map(int, input().split())

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

Submission status: Accepted

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=max(0,(K-A+1)//2)
    mod=(K-A+1)%2
    res=A+t*c+mod



print(res)




'''
Solve[{c=B/A, k=c-1,  t=(K-A+1)/2,r=A+t*k*A},{r}]
'''

Submission status: Accepted

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

    if K < (A - 1):
        return 1 + K
    else:
        if (B - A) >= 2:
            K -= (A - 1)
            q, r = divmod(K, 2)
            return A + q * (B - A) + r
        else:
            return 1 + K


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

Submission status: Accepted

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

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

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

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

    print(num)

Submission status: Accepted

Solution code:
def main():
    k,a,b=map(int, raw_input().split(" "))   
    if b-a<=2:    
        print(k+1)
        return
    x=a-1
    y=(k-x)/2
    z=k-x-2*y
    print(1+x+z+(b-a)*y)
    
main()

Submission status: Accepted

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
    K1=K-(A-1)
    bi+=((K1)//2)*(B-A)
    bi+=((K1)%2)
print(bi)

Submission status: Accepted

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

if B - A > 2 and A < K:
    print(A + (B - A) * max(0, (K - (A - 1)) // 2) + ((K - (A - 1)) % 2))
else:
    print(K + 1)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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
    #print(bi)
    K1=K-(A-1)
    #print(K-(A-1))
    bi+=((K1)//2)*(B-A)
    #print(((K1)//2)*(B-A))
    bi+=((K1)%2)
    #print(((K1)%2))
print(bi)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

if k <= a-1:
    print(k+1)
    exit()

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

Submission status: Accepted

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

Submission status: Accepted

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

def solve(K, A, B):
    r = 1
    if B - A <= 2:
        return r + K
    x = min(A - 1, K)
    r += x
    K -= x
    # print("*", r, K)
    if r >= A:
        x = K // 2
        r += x * (B - A)
        K -= x * 2
    # print("*", r, K)
    r += K
    K -= K
    return r

print(solve(K, A, B))

Submission status: Accepted

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

if b - a  >= 2 and a < k:
	n = k - a - 1
	if n % 2 == 0:
		bis = b + (b - a) * int(n / 2)
	else:
		bis = b + (b - a) * int(n // 2) + 1

else:
	bis = k + 1

print(bis)

Submission status: Accepted

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) * rest // 2
    else:
        cnt += (B - A) * ((rest - 1) // 2)
        cnt += 1
else:
    cnt += rest

print(cnt)

Submission status: Accepted

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:
        pass
    else:
        c1 += 1

    print(max(c1, k + 1))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
import math

lines = sys.stdin.readlines()
K, A, B = map(int, lines[0].split())
ans = 0

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

M = math.floor((K - (A-1)) / 2)
N = K - M * 2
ans = M * (B - A) +  N + 1

print(int(ans))

Submission status: Accepted

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

f = False

if a < b-1:
    f = True

if f == False:
    print(k + 1)

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

Submission status: Accepted

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

Submission status: Accepted

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 = (K - (A - 1))//2

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

print(ans)

Submission status: Accepted

Solution code:
s = input().split()
K = int(s[0])
A = int(s[1])
B = int(s[2])
 
bis = 1
 
if 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: Accepted

Solution code:
if __name__ == "__main__":
    K,A,B = map(int,input().split())
    
    if B - A <= 2:
        print(K + 1)
    else :
        #所持金がAになるのにA-1回の操作が必要
        if K <= A-1:
            print(1 + K)
        else:
            #残り回数
            rest = K - (A - 1)
            if rest < 2:
                print(1 + K)
            else:
                q,r = divmod(rest,2)
                print(A + q * (B - A) + r)

Submission status: Accepted

Solution code:
k,a,b=map(int,input().split())
i=a-1
c=a
j=k-i
c+=b*(j//2)
c-=a*(j//2)
print(max(k+1,c+j%2))

Submission status: Accepted

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

Submission status: Accepted

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 += 1
                counter += 1
        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: Accepted

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

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

Submission status: Accepted

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

ans = 0
K += 1

if K < A+2 :
    ans = K
elif 2 >= B-A :
    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())

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

print(res)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
k, a, b = map(int, input().split())

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

Submission status: Accepted

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 + 1:
        # 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: Accepted

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

if (B - A) / 2 <= 1 or K < A + 1: # ビスケットを叩くのが良い
    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: Accepted

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

if b<=a+2:
    print(1+k)
    exit()

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

Submission status: Accepted

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 + (req - 2): # 売買の成果が叩く成果以下なら売買する意味なし
        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: 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())
if K<=A or B<A+3 :
    ans=K+1
else:
    if (K-(A-1))%2==0 :
        ans=(B-A)*((K-(A-1))//2)+A
    else:
        ans = (B - A) * ((K - (A - 1)) // 2) + A + 1

print(ans)

Submission status: Accepted

Solution code:
k,a,b=map(int,input().split());K=k-(a+1);n=K//2;print(max(k+1,((n+1)*b-n*a+K%2)))

Submission status: Accepted

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

#お金に変えてからビスケットに変えるメリットがある場合
if B-A>2:
	b = 1
	K-=A-b
	b = A
	b+=(K//2)*(B-A)
	b+=K%2




else:
	b = 1+K

print(b)

Submission status: Accepted

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

#お金に変えてからビスケットに変えるメリットがある場合
if B-A>2:
	b = 1
	K-=A-b
	b = A
	b+=(K//2)*(B-A)
	b+=K-K//2*2




else:
	b = 1+K

print(b)

Submission status: Accepted

Solution code:
# coding: utf-8
import sys
# import bisect
# import math
# import numpy as np


"""Template"""


class IP:
    """
    入力を取得するクラス
    """
    def __init__(self):
        self.input = sys.stdin.readline

    def I(self):
        """
        1文字の取得に使います
        :return: int
        """
        return int(self.input())

    def S(self):
        """
        1文字の取得(str
        :return: str
        """
        return self.input()

    def IL(self):
        """
        1行を空白で区切りリストにします(int
        :return: リスト
        """
        return list(map(int, self.input().split()))

    def SL(self):
        """
        1行の文字列を空白区切りでリストにします
        :return: リスト
        """
        return list(map(str, self.input().split()))

    def ILS(self, n):
        """
        1列丸々取得します(int
        :param n: 行数
        :return: リスト
        """
        return [int(self.input()) for _ in range(n)]

    def SLS(self, n):
        """
        1列丸々取得します（str
        :param n: 行数
        :return: リスト
        """
        return [self.input() for _ in range(n)]

    def SILS(self, n):
        """
        Some Int LineS
        横に複数、縦にも複数
        :param n: 行数
        :return: list
        """
        return [self.IL() for _ in range(n)]

    def SSLS(self, n):
        """
        Some String LineS
        :param n: 行数
        :return: list
        """
        return [self.SL() for _ in range(n)]


class Idea:
    def __init__(self):
        pass

    def HF(self, p):
        """
        Half enumeration
        半分全列挙です
        pの要素の和の組み合わせを作ります。
        ソート、重複削除行います
        :param p: list : 元となるリスト
        :return: list : 組み合わせられた和のリスト
        """
        return sorted(set(p[i] + p[j] for i in range(len(p)) for j in range(i, len(p))))

    def Bfs2(self, a):
        """
        bit_full_search2
        bit全探索の改良版
        全探索させたら2進数のリストと10進数のリストを返す
        :return: list２つ : １個目 2進数(16桁)  2個目 10進数
        """
        # 参考
        # https://blog.rossywhite.com/2018/08/06/bit-search/
        # https://atcoder.jp/contests/abc105/submissions/4088632
        value = []
        for i in range(1 << len(a)):
            output = []

            for j in range(len(a)):
                if self.bit_o(i, j):
                    """右からj+1番目のiが1かどうか判定"""
                    # output.append(a[j])
                    output.append(a[j])
            value.append([format(i, 'b').zfill(16), sum(output)])

        value.sort(key=lambda x: x[1])
        bin = [value[k][0] for k in range(len(value))]
        val = [value[k][1] for k in range(len(value))]
        return bin, val

    def S(self, s, r=0, m=-1):
        """
        ソート関係行います。色々な設定あります。
        :param s: 元となるリスト
        :param r: reversするかどうか 0=False 1=True
        :param m: （2次元配列）何番目のインデックスのソートなのか
        :return: None
        """
        r = bool(r)
        if m == -1:
            s.sort(reverse=r)
        else:
            s.sort(reverse=r, key=lambda x: x[m])

    def bit_n(self, a, b):
        """
        bit探索で使います。0以上のときにTrue出します
        自然数だからn
        :param a: int
        :param b: int
        :return: bool
        """
        return bool((a >> b & 1) > 0)

    def bit_o(self, a, b):
        """
        bit探索で使います。1のときにTrue出すよ
        oneで1
        :param a: int
        :param b: int
        :return: bool
        """
        return bool(((a >> b) & 1) == 1)

    def ceil(self, x, y):
        """
        Round up
        小数点切り上げ割り算
        :param x: int
        :param y: int
        :return: int
        """
        return -(-x//y)

    def ave(self, a):
        """
        平均を求めます
        :param a: list
        :return: int
        """
        return sum(a) / len(a)


"""ここからメインコード"""


def main():
    # 1文字に省略
    r, e = range, enumerate
    ip = IP()
    id = Idea()

    """この下から書いてね"""
    k, a, b = ip.IL()
    K1 = k - (a + 1)
    n = K1 // 2
    print(max(k + 1, ((n + 1) * b - n * a + K1 % 2)))


main()

Submission status: Accepted

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

if abs(A-B) <= 1:
    print(K + 1)
elif A > B:
    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: Accepted

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


biscuits  = 1

if B - A > 2 and A <= K - 1:
    #最初にA枚までクッキーを増やす
    K -= A - 1
    biscuits += A - 1

    biscuits  += (B - A) * (K // 2)
    K -= (K // 2) * 2
    biscuits += K
else:
    biscuits  += K

print(biscuits)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def solve():
  K, A, B = map(int, input().split())
  if B - A <= 2: return K + 1 # 交換による利益なし
  if K - 1 < A: return K + 1  # 交換できる回数なし

  # ビスケットをAまで貯めれば、それ以降は継続した売り買いが可能
  # 売り買いの2回の操作で得られるのは、(B - A)分の利益
  # 残り操作回数が奇数だった場合、ビスケットを1枚増やす操作に割り当てる
  K -= A - 1
  N = K // 2
  mod = K % 2
  return A + (B - A) * N + mod

print(solve())

Submission status: Accepted

Solution code:
K, A, B = map(int,input().split())
biscuit = 1
yen = 0
if A >= B or B-A == 1:
    biscuit += K

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

print(biscuit)

Submission status: Accepted

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

if (k == 1):
    print(2)
    exit()

if (b <= (a + 1)):
    print(k + 1)
    exit()
else:
    tmp1 = k - (a - 1)
    sabun = b - a

    if (tmp1 % 2 == 0):
        bis = int((tmp1 / 2 - 1)) * int(sabun) + b
    else:
        zouka = int((tmp1 // 2 - 1)) * int(sabun)
        bis = zouka + b + 1

    print(bis)

Submission status: Accepted

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

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

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

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

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

print(bis)

Submission status: Accepted

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

Solution code:
nData = []
nData  = input().rstrip().split(' ')

nAns=0
nK = int(nData[0])
nA = int(nData[1])
nB = int(nData[2])

if (nA>=nB-1) or (nA>=nK):
 nAns=nK+1
else:
 nTmp=nK - (nA-1)
 nTmp1=nTmp//2
 nTmp2=nTmp%2
 nAns=nA+(nB-nA)*(nTmp1)+nTmp2

print(nAns)

Submission status: Accepted

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

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

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

ans += K

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

first_bis = min(K,A)-1
second_exchange = int((K-first_bis)/2)
final_bis = K-first_bis-second_exchange*2

if A<B-1:
    bis = 1+first_bis+second_exchange*(B-A)+final_bis
else:
    bis = K+1
    
print(bis)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
# ----------------------------------------------------------------
# Use Solve Function

def solve(lines):
    K,A,B = map(int, lines.pop(0).split(' '))
    if A >= B:
        print(K+1)
        sys.exit(0)
    elif B - A <= 2:
        print(K+1)
        sys.exit(0)

    if K < A+1:
        print(K+1)
        sys.exit(0)
    elif K == A+1 and K > B:
        print(K+1)
        sys.exit(0)

    K -= A+1
    res = B

    n = int(K / 2)
    res += n*(B-A)
    K -= 2 * n

    if K == 1:
        res += 1

    print(res)

#
# main
#
lines = [x.strip() for x in sys.stdin.readlines()]

#
# solve !!
#
solve(lines)

Submission status: Accepted

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

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

# 交換するまで枚数が増えない
# 交換しない方が価値がある
if K + 2 < A or A + 2 > B:
    cookie = 1 + K
else:

    exchangeCount = (K - (A - 1)) // 2
    extraTapCount = (K - (A - 1)) % 2

    cookie = A

    cookie += (B - A) * exchangeCount

    cookie += extraTapCount

print(cookie)

Submission status: Accepted

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

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

print(res)

Submission status: Accepted

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

def f(K, A, B):
    if A >= B - 2 or K <= A:
        return K + 1
    
    # then A < K and A < B

    # break cookies for (A-1) times
    K -= (A - 1)
    if K % 2 == 0:
        return A + (B - A) * (K // 2)
    else:
        return 1 + A + (B - A) * (K // 2)
    
ans = f(K, A, B)
print('%d'%ans)

Submission status: Accepted

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))

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

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

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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 - 1)
    ans = (ka // 2 - 1) * (B - A) + B
    if ka % 2 == 1:
        ans += 1
    return max(K + 1, ans)


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

Submission status: Accepted

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

Submission status: Accepted

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


bis = 1

kaisu = 0

en = 0

if B <= A +  1:
    bis = bis + K
elif K <= 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:
        #print("test")
        w1 = int(K /2)
        w2 = B-A
        bis = bis + w1*w2
    else:
        #print("test2")
        w1 = int(K /2)
        w2 = B-A
        bis = bis + w1*w2 
        bis = bis +1


print(bis)

Submission status: Accepted

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

elif B-A==1:
    print(K+1)
    exit(0)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
k,a,b=map(int,input().split())
ans=0
if a+1<=k and b>a+2:
  k=k-(a+1)
  ans+=b
  mul,mod=divmod(k,2)
  ans+=(mul)*(b-a)
  ans+=mod
  print(ans)
else:
  print(1+k)

Submission status: Accepted

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

Submission status: Accepted

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

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)  #交換可能回数
    #print(moving)
    if moving > 0:
        #print("m")
        bis = B
        K-=A+1
    else:
        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: Accepted

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) * int(K / 2)
        K = K % 2
    else:
        ans += 1
        K -= 1

print(ans)

Submission status: Accepted

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

ans = 1
money = 0

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

else:
	ans += K

print(ans)

Submission status: Accepted

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回目
        K = K - (A + 1)
        N = B
        if K > 0:
            # 売る買うを繰り返す
            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: Accepted

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

Submission status: Accepted

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

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

print(bs)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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=B+(en-1)*(B-A)
    #print(bis)
    n=n%2
  if n==0:
    ans=bis
  else:
    ans=bis+n
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
a,b,c=map(int, input().split(" "))
ans1=a+1
#ans2=(a-1)%b+math.floor((a-1)/b)*c
num1=a-b+1
#print(c*(math.floor(num1/2)))
#print(b*(math.floor(num1/2)))
#print((c-(b-1))*(math.floor(num1/2)))
ans2=((c-b))*(math.floor(num1/2))
ans2+=b+num1%2
#print()
#print(math.floor(a/b)*c)
#print(math.floor((a+1)%b))
print(max(ans1,ans2))

Submission status: Accepted

Solution code:
# coding: utf-8
k, a, b = map(int, input().rstrip().split())

#a-bを計算しa-b >= -2の場合ポケットを叩き続けた方が最大になる
sub = a - b
if sub >= -2:
    biscuit = 1 + k
    print(biscuit)
    exit()

#ビスケットと1円を交換できるようになるまでに必要な回数
time = a - 1
#k回までに全部で何回交換（ビスケット→円→ビスケット)できるか
can_do = int((k-time)/2)
if (k-time)%2 == 0:
    ans = a + can_do*(b-a)
else:
    ans = a + can_do*(b-a) + 1

print(ans)

Submission status: Accepted

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

bisket = 1

if B <= A + 1 :
    bisket = K + 1
elif K <= A :
    bisket = K + 1
else :
    exCount =  (K + 1 - A) // 2
    hit = (K + 1 - A) % 2
    bisket = exCount * (B-A) + A + hit

print(bisket)

Submission status: Accepted

Solution code:
K, A, B = (int(i) for i in input().split())
num = 1
while True:
    if A + 2 - num >= B:
        print(K + num)
        break
    elif num >= A and (K // 2) is not 0:
        print(num + (K // 2) * (B - A) + (K % 2))
        break
    elif K >= 2 and K >= (A + 2 - num):
        K -= (A + 2 - num)
        num = B
    else:
        print(K + num)
        break