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())
q, r = divmod(k-a+1, 2)
print(max(q*(b-a) + r + a, k+1))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')
k, a, b = LI()

# a 枚を 1 円に交換、1 円を b 枚に交換 の 2 回の操作で b - a 枚増える
if b - a <= 2:
    print(1 + k)
    exit()

rest_k = k - (a - 1)  # 初めに a 枚になるまで増やした後の残り回数
if rest_k < 0:
    ans = 1 + k  # a 枚にすることができないならただ k 枚増やす
else:
    ans = a
    # 残りの操作回数で 可能な限り b - a 枚増やす操作を行う
    ans += (b - a) * (rest_k // 2)
    ans += rest_k % 2  # 残りが奇数回なら最後の １ 回は 1 枚増やす
print(ans)

Submission status: Accepted

Solution code:
k, a, b = map(int, input().split())
bis = 1
if b - a <= 2:
    bis += k
else:
    while k != 0:
        if bis >= a and k >= 2:
            bis += b - a
            k -= 2
        else:
            bis += 1
            k -= 1
print(bis)

Submission status: Accepted

Solution code:
K,A,B = map(int, open(0).read().split())
if B - A <= 1:
    print(K+1)
else:
    if K < A + 1:
        print(K+1)
    else:
        dm = divmod(K-A-1,2)
        print((dm[0]*(B-A)+B+dm[1]))

Submission status: Accepted

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')


def solve():
    k, a, b = [int(x) for x in input().split()]
    if b - a > 2:
        # i need a - 1 ops to make 1 yen (and one biscuit for the operetion itself)
        # i need even number of ops (which are left now)
        # if there is odd number its just +1 to result
        ops = k - a + 1
        print(max(k + 1, (b - a) * (ops // 2) + a + (ops % 2)))

    else:
        print(k + 1)

t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""

1 + k



"""

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def check(k,ans):
    if k<2:
        print(ans+k)
        exit()

def main():
    k,a,b=MI()
    d=b-a
    if d<3:
        print(k+1)
        exit()
    ans=1
    cnt=min(a-1,k)
    ans+=cnt
    k-=cnt
    check(k,ans)
    cnt=k//2
    ans+=cnt*d
    k-=cnt*2
    check(k,ans)

main()

Submission status: Accepted

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

if B - A <= 2:
    print(K + 1)
else:
    ans = 0
    # 初回のA枚→B枚まで A-1 回かかる
    rest = K - A + 1
    # このときにはA枚持っている
    ans += A
    # 残りをすべてA枚→B枚
    ans += rest // 2 * (B - A)
    if rest % 2 != 0:
        ans += 1
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

    if K <= A:
        print(K+1)
        return

    res = A

    K -= A-1
    if K % 2 == 1:
        res += 1
        K -= 1

    res += (K//2) * (B-A)
    
    print(res)
    return

f()

Submission status: Accepted

Solution code:
from collections import defaultdict
from collections import deque
import itertools
import math

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

k,a,b = readInts()

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

print(ans)

Submission status: Accepted

Solution code:
def resolve():
    '''
    code here
    '''
    K, A, B = [int(item) for item in input().split()]

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


if __name__ == "__main__":
    resolve()

Submission status: Accepted

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

# In[5]:


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


# In[6]:


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


# In[ ]:

Submission status: Accepted

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


def read():
    K, A, B = list(map(int, input().strip().split()))
    return K, A, B


def solve(K, A, B):
    ans = 1
    if B-A <= 1:
        ans += K
        return ans
    if K < A-1:
        ans += K
        return ans
    ans += (A-1)
    k = K-A+1
    ans += (B-A) * (k//2) + k % 2
    return ans


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import bisect,collections,copy,heapq,itertools,math,string
import sys
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

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

Submission status: Accepted

Solution code:
import sys

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

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

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

Submission status: Accepted

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

ans = 1
if A >= B:
    ans += K
else:
    restk = K
    # A < B
    restk -= A - 1

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

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/yahoo-procon2019-qual/tasks/yahoo_procon2019_qual_c
# ビスケットを1枚増やす:1回
# ビスケットをA→B枚にする:2回

# 最適戦略
# 手持ち<AのときAまで増やさないと交換できない
# B-A>2のときに限って、交換し続けるのが得にな


import sys


def exit(*argv, **kwarg):
    print(*argv, **kwarg)
    sys.exit()


K, A, B = map(int, input().split())
if A - 1 >= K:  # コーナーケース、A枚になる前にK回に達する
    exit(K + 1)

if B - A > 2:
    # A枚まで増やす
    K -= (A - 1)
    # 可能な限りA→Bに変換する
    times, r = divmod(K, 2)
    print(r + times * (B - A) + A)
else:
    print(K + 1)

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
#みんなのプロコン2019-C
k,a,b = map(int,input().split())

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

Submission status: Accepted

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

ans=0

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

    k-=2*exchange
    ans+=k

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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


# 持っているビスケットを叩き、1枚増やす
# ビスケット A枚を 1円に交換する
# 1円をビスケット B枚に交換する
def main():
    k, a, b = input_list()
    # 交換レートが同じなら叩き続けたほうがいい 交換には手数２回消費つまりA + 3 <= B
    if b-a <= 2:
        print(k+1)
    else:
        bis = a
        k -= a-1
        if k % 2 == 1:
            bis += 1
            k -= 1
        bis += (b-a)*(k//2)
        print(bis)


def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)


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


def input_list_str():
    return list(map(str, input().split()))


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
K,A,B = map(int,input().split())
if K+1<=A:
    print(K+1)
else:
    if A+2>=B:
        print(K+1)
    else:
        #A+2枚→B枚
        #この状態になると叩くよりも交換した方が得
        #2回でB-A枚増えていく
        #奇数偶数で場合わけ
        if (K-A-1)%2==0:
            print(A+(B-A)*((K-A+1)//2))
        else:
            print(A+1+(B-A)*((K-A+1)//2))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
k,a,b= map(int,input().split())
cur = 1
#交換しないほうがいい
if b - a <= 2:
  print(cur + k)
  exit()
#交換できない
if cur + k <= a+1:
  print(cur + k)
  exit()
#交換するまで増やす
cur, k, = a, k-a+cur
#偶数回交換する
cur += (b - a) * (k // 2)
k %= 2
#最後に足す
cur += k
print(cur)

Submission status: Accepted

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

# 2手かけて増えるのが2枚以下なら地道に増やす
if b-a <= 2:
    print(1+k)
else:
    k -= a-1
    q,r = divmod(k,2)
    print(a+q*(b-a)+r)

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *

K, A, B = MAP()

if A+1 >= B or A >= K:
	print(1 + K)
else:
	ans = A
	K -= A-1
	n, left = divmod(K, 2)
	ans += n*(B-A) + left
	print(ans)

Submission status: Accepted

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

if b - a <= 2:
    print(k + 1)
else:
    k = k - (a - 1)
    cnt = a

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

Submission status: Accepted

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

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

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

ans = 1
ans += a - 1
q, r = divmod(k - (a - 1), 2)
ans += (b - a) * q
ans += r
ans = max(ans, k + 1)

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
K, A, B = map(int, input().split())
# 1円に交換するためにはA枚のビスケットがいる　操作１
# B枚のビスケットにするためには1円がいる　操作２
# 持っているビスケット(０個でもいい)を叩けば一個ビスケットが得られる　操作３

# A > B
# A == B
# A < B

if (K == 1):
    print(K + 1)
    exit()

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

elif (A < B):
    # 1円を作るたびに操作３を実行
    nokori = K - (A - 1)
    bis = A
    for _ in range(A):
        if (nokori % 2 != 0):
            nokori -= 1
            bis += 1
        else:
            break

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

if(k<=a-1):
    print(k+1)
elif(b<a+2):
    print(k+1)
else:
    bis+=a-1

    rest=k-(a-1)
#    print(bis,rest)

    exc=rest//2

    bis=(exc*b - (exc-1)*a)

    if(rest%2==1):
        bis+=1

    print(bis)

Submission status: Accepted

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

st = max(0, (k-(a-1))//2)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
from itertools import permutations,combinations,groupby
import sys,bisect,string,math,time,functools,random
def Golf():*a,=map(int,open(0))
def I():return int(input())
def S_():return input()
def IS():return input().split()
def LS():return [i for i in input().split()]
def LI():return [int(i) for i in input().split()]
def LI_():return [int(i)-1 for i in input().split()]
def NI(n):return [int(input()) for i in range(n)]
def NI_(n):return [int(input())-1 for i in range(n)]
def StoLI():return [ord(i)-97 for i in input()]
def ItoS(n):return chr(n+97)
def LtoS(ls):return ''.join([chr(i+97) for i in ls])
def GI(V,E,Directed=False,index=0):
    org_inp=[];g=[[] for i in range(n)]
    for i in range(E):
        inp=LI();org_inp.append(inp)
        if index==0:inp[0]-=1;inp[1]-=1
        if len(inp)==2:
            a,b=inp;g[a].append(b)
            if not Directed:g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp;aa=(inp[0],inp[2]);bb=(inp[1],inp[2]);g[a].append(bb)
            if not Directed:g[b].append(aa)
    return g,org_inp
def GGI(h,w,boundary=1,search=[],replacement_of_found='.',mp_def={'#':1,'.':0}):
#h,w,g,sg=GGI(h,w,boundary=1,search=['S','G'],replacement_of_found='.',mp_def={'#':1,'.':0}) # sample usage
    mp=[boundary]*(w+2);found={}
    for i in range(h):
        s=input()
        for char in search:
            if char in s:
                found[char]=((i+1)*(w+2)+s.index(char)+1)
                mp_def[char]=mp_def[replacement_of_found]
        mp+=[boundary]+[mp_def[j] for j in s]+[boundary]
    mp+=[boundary]*(w+2)
    return h+2,w+2,mp,found
def TI(n):return GI(n,n-1)
def bit_combination(k,n=2):return [[tb//(n**bt)%n for bt in range(k)] for tb in range(n**k)]
def show(*inp,end='\n'):
    if show_flg:print(*inp,end=end)
def show2d(g,h,w):
    for i in range(h):show(g[i*w:i*w+w])

YN=['YES','NO'];Yn=['Yes','No']
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
#sys.setrecursionlimit(10**7)
input=lambda: sys.stdin.readline().rstrip()

show_flg=False
show_flg=True




k,a,b=LI()

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

print(ans)

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *

K, A, B = MAP()

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

k = K - (A-1)  #ちょうどA枚になった時の残りの回数
ans = A + k//2*(B-A) + k%2
print(ans)

Submission status: Accepted

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


print(int(ans))

Submission status: Accepted

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

    if A >= B:
        ans = K + 1
    else:

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

        else:
            if K >= A - 1 + 2:
                ans += B
                K -= (A + 1)

                if abs(A - B) <= 2:
                    r, m = divmod(K, A)
                    ans += r * B + m
                else:
                    r, m = divmod(K, 2)
                    ans += (B - A) * r + m
            else:
                ans = K + 1

    print(ans)

if __name__ == "__main__":
    main()

Submission status: Accepted

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

print(max(bis,tempbis))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


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

    if b - a < 2 or k - a < 1:
        print(k + 1)
    else:
        k -= a - 1
        q, k = divmod(k, 2)
        res = a + q * (b - a) + k
        print(res)


if __name__ == '__main__':
    resolve()

Submission status: Accepted

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

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

cnt += (a-ans)
ans += (a-ans)


#まとめてa枚をb枚に交換
n = (k-cnt)//2
ans-= a * n
ans+= b * n
cnt+= 2 * n

#残り回数でビスケットをわる
ans += k-cnt

print(ans)

Submission status: Accepted

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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from collections import Counter
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()

#####Shorten#####
def DD(arg): return defaultdict(arg)


#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####MakePrimes######
def make_primes(N):
  max = int(math.sqrt(N))
  seachList = [i for i in range(2,N+1)]
  primeNum = []
  while seachList[0] <= max:
    primeNum.append(seachList[0])
    tmp = seachList[0]
    seachList = [i for i in seachList if i % tmp != 0]
  primeNum.extend(seachList)
  return primeNum

#####GCD#####
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i-1])*n**i for i in range(len(str(X))))

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
#############
K,A,B = IL()

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

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

else:
  n=(k-(a-1))#交換できる回数。
#  print('n:',n)
  if n%2==1:
    print((n-1)//2*(b-a)+(k-n)+1+1)
  else:
    print(n//2*(b-a)+(k-n)+1)

Submission status: Accepted

Solution code:
k, a, b = map(int, input().split())
ans = 0
if b - a <= 1: # 叩き続けたほうがいい
    ans = k + 1
else:
    n = k - a + 1 #a個
    if n % 2 == 1:
        ans = a + 1 + (b-a)*(n//2) #最後交換しない
    else:
        ans = a + (b-a)*(n//2) 
print(ans)

Submission status: Accepted

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

# ビスケットa枚を1円に交換し、1円をb枚に交換するという操作を考えると、
# これは操作回数を2回消費して b - a 枚だけビスケットが増える
# よって、 b - a > 2 で残り回数が2回以上なら
# ビスケットを叩いて1枚増やすより常に有利なのでやるべし。

biscuits = 1
if b - a > 2:
    # 何回できる?
    # 最初に a - 1回叩いてビスケットを a 枚に増やす必要がある
    if a - 1 > k:
        # a枚まで増やせないので k 回叩いて終わる
        biscuits += k
    else:
        # a枚まで増やした
        biscuits += a - 1
        k -= a - 1
        if k > 0:
            times = k // 2
            rest = k - times * 2
            biscuits += (b - a) * times
            biscuits += rest
else:
    # 常に叩いて1枚増やすほうがマシ
    biscuits += k

print(biscuits)

Submission status: Accepted

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

if A+2>=B:
    ans = 1+K
else:
    k = K-A+1 #初回にA枚まで増やした後の回数
    ans = A + k//2 * (B-A)
    if k%2:
        ans += 1
print(ans)

Submission status: Accepted

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

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

chage_turn = 2
ans = 0
K -= A - 1 + chage_turn
ans += B
ans += K//2 * (B-A) + K%2
print(ans)

Submission status: Accepted

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

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
k, toayen, fromayen = map(int, input().split())
ans1 = k + 1
k -= (toayen - 1)
d, m = divmod(k, 2)
ans2 = (fromayen - toayen) * d + toayen + m
print(max(ans1, ans2))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15

def main():
    K,A,B = map(int,input().split())
    if B - A >= 2:
        K -= A - 1
        ans = A + (B - A) * (K//2) + K%2
    else:
        ans = K + 1
    print(ans)
if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

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

tataku = A - 1
if (A > B) or (A >= K) or (A + 1 == B): #  or (tataku + 1 >= K):
    print(K+1)
else:
    c = B
    nokori = K - tataku - 2
    if nokori % 2 == 1:
        c += (B-A) * (nokori//2) + 1
    else:
        c += (B-A) * (nokori//2)

    print(c)

Submission status: Accepted

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

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

ans = 1

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

Submission status: Accepted

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

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

K -= A - 1
res = A

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

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

print(res)

Submission status: Accepted

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

if B-A<=2:
    b_count+=K
else:
    b_chenge_count=max(0,int((K-(A-1))/2))
    b_count+=b_chenge_count*(B-A)+(A-1)+(K-(A-1)-b_chenge_count*2)

print(b_count)

Submission status: Accepted

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

if B-A<=2:
    b_count+=K
else:
    b_chenge_count=max(0,int((K-(A-1))/2))
    b_count=b_chenge_count*(B-A)+(A)+(K-(A-1)-b_chenge_count*2)

print(b_count)

Submission status: Accepted

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

if (b - a) < 2:
    ans = 1 + k

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

if B - A <= 2 or K <= A: #交換しても増やせないorお金をビスケットに交換できない
    ans = K + 1
else:
    n = K - (A + 1)
    n_loop =  n // 2
    n_tataku = n % 2
    ans = B + n_loop * (B-A) + n_tataku
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:


K,A,B=map(int, input().split())
#操作K回ビスケットを最大化
if A+2>=B:
    print(K+1)
    exit()

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

print(ans)