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:
k, a, b = map(int, input().split())
if k <= a or b - a < 3:
    ans = k + 1
else:
    ans = a
    k -= a - 1
    if k % 2 == 1:
        k -= 1
        ans += 1
    ans += k // 2 * (b - a)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

max_n = (K-A-1)//2
mod = (K-A-1)%2

if A+2 >= B:
  print(K+1)
elif K < A+1:
  print(K+1)
else:
  print(B+max_n*(B-A)+mod)

Submission status: Accepted

Solution code:
k,a,b = map(int,input().split())
coin = 0
i = 0
if b-1 > a and a-1 <= k :
    #交換できるならした方がいい
    #a枚溜めた後の残りの交換回数
    times = (k-a+1)//2
    #叩く回数
    times_hit = (k-a+1)%2

    #合計
    coin = a + (b-a)*times+times_hit
    print(coin)
else:
    #叩くだけを繰り返す
    print(k+1)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

if a + 1 >= b:
    print(k + p)
else:
    c = min(k, a - p)
    p += c
    k -= c
    if k == 0:
        print(p)
    else:
        p += (-a + b) * (k // 2)
        k = k % 2
    
    if k == 1:
        print(p + 1)
    else:
        print(p)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def f():
    a = list(map(int, input().split()))
    if a[0] <= a[1]:
        print(a[0]+1)
        return
    b = a[2]-a[1]
    print(((a[0]-a[1]+1)//2)*b+(a[0]-a[1]+1)%2+a[1] if b > 2 else a[0]+1)
f()

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

    kanekai=(k-(a+1))//2

    ans=kanekai*(b-a)+b
    if (k-(a+1))%2!=0:
        ans+=1
    return ans



print(mc())

Submission status: Accepted

Solution code:
k,a,b = (int(num) for num in input().split())
ans = 0
if a-b >= -2:
    ans = k+1
elif k <= a-1:
    ans = k+1
else:
    n_yen = (k-a+1)//2
    ans = k+1 - n_yen*2 + n_yen*(b-a)
print(ans)

Submission status: Accepted

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

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

print(biscuits)

Submission status: Accepted

Solution code:
# _*_ coding:utf-8 _*_
#  Atcoder_YahooMinnanoProcon_Contest-C
#  TODO https://atcoder.jp/contests/yahoo-procon2019-qual/tasks/yahoo_procon2019_qual_c

def solveProblem(operation,bis2moneyone,onemoney2bis):
	if (onemoney2bis-bis2moneyone) <= 1:
		# This case all hit pocket
		answer=operation+1
	else:
		# まず、お金と交換できるまでのビスケットが起点になる
		answer = bis2moneyone
		# たたいて後から出来る操作数
		remainOperation = operation - ( bis2moneyone - 1)
		# ビスケット⇔お金の操作可能数。
		changeMoney2Bis = remainOperation // 2
		# その分ビスケット→お金→ビスケットにしたときの差が増やせる
		answer = answer + changeMoney2Bis * ( onemoney2bis - bis2moneyone)
		# さらに操作が可能か。可能であればプラスする
		answer = answer + remainOperation % 2

	return answer


if __name__ == '__main__':
	K,A,B = map(int,input().strip().split(' '))
	solution = solveProblem(K,A,B)
	print("{}".format(solution))

Submission status: Accepted

Solution code:
K,A,B = (int(x) for x in input().split())
total = 0
if(B-A<3):
    print(K+1)
    exit()
else:
    if((K-(A+1))%2 == 0):
        print(B + (K-(A+1))//2*(B-A))
    else:
        print(B + (K-(A+1))//2*(B-A) + 1)

Submission status: Accepted

Solution code:
'''input
314159265 35897932 384626433
'''
import time
import math
k, a, b = map(int, input().strip().split())
if b > a + 2:
	ans = 1
	if(ans < a):
		ans += min(a - 1, k - 1)
		k -= min(a - 1, k - 1)
	if k % 2 == 1:
 		ans += 1
 		k -= 1
	ans = ans - (a * (k // 2))
	ans = ans + (b * (k // 2))
	print(ans)
else:
	ans = 1 + k
	print(ans)

Submission status: Accepted

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

if (B-A) < 3 :
    print(K+1)
else :
    print((B-A) * math.floor(max(0,(K+1-A)/2)) + A + (K+1-A)%2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
k,a,b=map(int,input().split(" "))
x=1
count=0
if a>b or b-a<2:
  print(k+1)
  exit()
if x<a and k-count>=a-x:
  count+=a-x
  x=a
c,ex=divmod((k-count),2)
x+=(b-a)*c
if ex==1:
  x+=1
print(int(x))

Submission status: Accepted

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

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

else:print(k+1)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

if B-A <= 2:
    print(K+1)
else:
    c = max(0,K-(A-1))//2
    print((B-A)*c + K-c*2+1)

Submission status: Accepted

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

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

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

print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# みんなのプロコン 2019：C - When I hit my pocket...


def main():
    K, A, B = [int(i) for i in raw_input().strip().split(' ')]

    if B - A > 2:
        bis = 1

        b = A - 1
        l = K - b
        bis += b

        b = (l / 2) * (B - A)
        l = l - (l / 2) * 2
        bis += b

        bis += l

        print bis
    else:
        print 1 + K


if __name__ == '__main__':
    main()

Submission status: Accepted

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


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

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# your code goes here
K, A, B = [int(s) for s in input().split()]
if B-A > 2:
	b = 1
	k_hit = min(K, A-b)
	K -= k_hit
	b += k_hit
	k_trade, k_hit = divmod(K, 2)
	b += k_trade*(B-A) + k_hit
else:
	b = K+1

print(b)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def calc_max_biscuit(K,A,B):
    #ビスケットを売り買いして得る儲けが1以下なら、K回ポケットを叩いた結果を返す。
    hit_only = 1+K
    sell_and_buy = 0
    if B-A<1:
        print(hit_only)
    else:
        K -= (A-1)
        if K%2==0:
            sell_and_buy = A + int(K/2)*(B-A)
        else:
            sell_and_buy = A + int(K/2)*(B-A)+1
        print(max(sell_and_buy, hit_only))
        
K, A, B = list(map(int, input().split()))
calc_max_biscuit(K,A,B)

Submission status: Accepted

Solution code:
def solve():
    k, a, b = map(int, input().split())
    if a > b - 2 or k + 1 < a:
        return k + 1
    ans = a
    k -= (a - 1)
    return ans + (k & 1) + (b - a) * (k // 2)
print(solve())

Submission status: Accepted

Solution code:
k, a, b = map(int, input().split())
if a + 1 >= b:
    print(k + 1)
elif k <= a - 1:
    print(k + 1)
else:
    remain = k - (a - 1)
    d, m = divmod(remain, 2)
    ans = a + (b - a) * d + m
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def biscuit():
    cost,A,B=map(int,input().split())
    maisu=1
    if B-A<=2:
        return cost+1
    else:
        cost-=A-1#最初にA枚集まるまで殴り続ける
        maisu=A
        pocket=cost%2
        yen=cost//2
        return maisu+pocket+yen*(B-A)
print(biscuit())

Submission status: Accepted

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

Submission status: Accepted

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

    ans = k + 1  # hit every time

    if a+1 < b:    # exchange benefits
        u = k-a+1  # remaining steps after hitting A times

        # After hitting A times,
        # make B-A biscuits is produced every 2 steps
        # if u is odd, hit one at the last step.
        ans = a + u//2*(b-a) + u%2
    print(ans)


solve()

Submission status: Accepted

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

Submission status: Accepted

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

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

#copy code

Submission status: Accepted

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

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

#copy code

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

print(max((b-a) * (k//2)+ 1 * (k % 2) + bis,k + bis))
#copy code

Submission status: Accepted

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

if a>b or k < a+1 or b-a <3:
    print(k+1)
    exit()
else:    
    hit = max([0,int((k-(a-1))/2)])
    ans = (b-a) *hit
    temp = k-(hit*2)
    print(ans+temp+1)

Submission status: Accepted

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

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

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

Submission status: Accepted

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

    if k % 2 == 1:
        ans += 1
else:
    ans = k + 1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

bisk += K
print(bisk)

Submission status: Accepted

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

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

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

        print(bisket)

Submission status: Accepted

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

Submission status: Accepted

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

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

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

c = a
k = k - (a-1)
money = 0

n = k // 2
cc = c + (b-a) * n
if (k % 2) == 1 :
    cc += 1

print (cc)

Submission status: Accepted

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

main()

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

    if a >= b - 2:
        print(1 + k)

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

main()

Submission status: Accepted

Solution code:
KAB = [int(x) for x in input().split()]
K = KAB[0]
A = KAB[1]
B = KAB[2]
count = 1
if (B - A <= 2) or K <= A:
    print(K + 1)
else:
    count = A
    K = K - A + 1
    if K % 2 == 1:
        count = count + 1 + (B - A) * (K // 2)
    else:
        count += (B - A) * K // 2
    print(count)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Feb  9 20:41:09 2019

@author: shinjisu
"""


# 2019/2/9 Yahoo
def getInt(): return int(input())


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


def getIntLines(n): return [int(input()) for i in range(n)]


def zeros(n): return [0]*n


def db(x):
    global debug
    if debug:
        print(x)


def probA():
    N, K = getIntList()
    db((N, K))
    if (N+1)//2>=K:
        return 'YES'
    else:
        return 'NO'


def probB():
    a, b = zeros(3), zeros(3)
    db((a,b))
    for i in range(3):
        a[i], b[i] = getIntList()
    db((a,b))
    c = set([])
    e = zeros(5)
    for i in range(3):
        c.add(a[i])
        c.add(b[i])
        e[a[i]] += 1
        e[b[i]] += 1
    db((c,e))
    c0,c1,c2,c3,c4=0,0,0,0,0
    for i in range(1, 5):
        if e[i]==0:
            c0 += 1
        elif e[i] == 1:
            c1 += 1
        elif e[i] == 2:
            c2 += 1
        elif e[i] == 3:
            c3 += 1
        else:
            c4 += 1
    db((c0,c1,c2,c3,c4))
    if c1 == 2 and c2 == 2: 
        return 'YES'
    else:
        return 'NO'


def probC():
    K, A, B = getIntList()
    db((K,A,B))
    if B-A < 3:
        bCount = 1 + K
    elif 1+K < A:
        bCount = 1 + K
    else:
        remK = 1+K-A  # ビスケットはA枚
        db(remK)
        bCount = A
        bCount += remK//2*(B-A)
        bCount += remK % 2
    return bCount


def issuedCode():
    for i in range(1, 10**9):
        if (1+K-i*2)//A==i:
            break
        db(i)
    bCount = B*i + (K-2*i)


debug = False
print(probC())

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#B
"""
def find(x):
    while table[x] >= 0:
        x = table[x]
    return x

def union(x, y):
    s1 = find(x)
    s2 = find(x)
    if s1 != s2:
        if table[s1] != table[s2]:
            if table[s1] < table[s2]:
                table[s2] = s1
            else:
                table[s1] = s2
        else:
            table[s1] -= 1
            table[s2] = s1
    return
    


a1, b1 = map(int, input().split())
a2, b2 = map(int, input().split())
a3, b3 = map(int, input().split())

ans = [0 for i in range(4)]

ans[a1-1] += 1 
ans[a2-1] += 1 
ans[a3-1] += 1 
ans[b1-1] += 1 
ans[b2-1] += 1 
ans[b3-1] += 1 

if 0 in ans or 3 in ans:
    print("NO")
else:
    print("YES")
"""

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

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

Submission status: Accepted

Solution code:
k,a,b = map(int,input().split())
p = a-1
q, r = divmod(k-p, 2)

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def c_biscuit(K, A, B):
    # B <= A+2 の場合、ビスケットと日本円を交換する意味がない(2手に対して利益がない)。
    # A >= K の場合、ビスケットと日本円を交換できるほどビスケットが貯まらない。
    if B <= A + 2 or A >= K:
        return K + 1

    # ビスケットがA枚以上あり、かつ、残りの操作回数が2回以上あるなら、操作を2回行い、
    # ビスケットA枚をB枚に変換できる。この変換が可能な回数はmax(0, (K-(A-1))//2)回。
    # もし、上の変換を行ったあと、操作回数が余っていたら(最大1回)、それでビスケットを増やす。
    # この処理を行う場合、 A < K すなわち K+1 >= A ゆえに K-(A-1)>=0 なので、
    # 負数を割ったりmodを取ったりするおそれはない。
    exchange_time, final_remain = divmod(K - (A - 1), 2)
    ans = A + (B - A) * exchange_time + final_remain
    return ans

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

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

print(bis)

Submission status: Accepted

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

sum = 0
if a >= b:
    # A >= Bの場合
    # a,bに１施行ずつ使い、それ以外は叩く、という選択
    sum = k + 1
else:
    # A < B の場合
    diff = b - a
    if diff == 1:
        sum = k + 1
    elif diff == 2:
        sum = k + 1
    elif diff >= 3:
        # a->bコンボが利潤を生み続けるパターン
        rest = 1 + k - a
#         print("K:{}".format(rest))
        if rest >= 0:
            if rest % 2 == 0:
                sum = a + ((diff) * int(rest / 2))
#                 print("biscuits:{}".format(a))
#                 print("diff:{}, k/2:{}".format(diff, rest / 2))
            else:
                # 最後1回はコンボができないので、叩くパターン
                sum = a + ((diff) * int((rest - 1) / 2)) + 1
#                 print("biscuits:{}".format(a))
#                 print("diff:{}, k/2:{}".format(diff, (rest - 1) / 2))
        else:
            sum = k + 1
                
print(int(sum))

Submission status: Accepted

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

cookie = 0

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

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

Submission status: Accepted

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

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

def main():
    if (B - A < 2 or A > K - 1):
        print(K+1)
    else:
        count = K - A + 1
        ans = A
        if count % 2 != 0:
            count -= 1
            ans += 1
        ans += count//2 * (B - A)
        print(ans)

if __name__ == "__main__":
    main()

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+2>=b:print(k+1)
elif a>=k:print(k+1)
else:
    k-=(a-1)
    ans=a+(b-a)*(k//2)
    if k%2==1:print(ans+1)
    elif k%2==0:print(ans)