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 B - A <= 2 or K < A + 1:
  print(K+1)
else:
  cnt = A - 1
  bisket = 1 + cnt + (B - A) * ((K - cnt)//2)
  bisket += (K - cnt) % 2
  print(bisket)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
k, a, b = [int(i) for i in sys.stdin.readline().split()]
if b - a <= 2:
    print(k + 1)
else:
    cnt = 0
    cnt += min(k, a - 1)
    bisk = 1 + cnt + (b - a) * ((k - cnt) // 2)
    bisk += (k - cnt) % 2
    print(bisk)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

if B - A <= 2:
    print(1 + K)
elif A + 1 > K:
    print(1 + K)
else:
    rest = K - A + 1
    b = (rest // 2) * (B - A) + rest % 2 + A
    print(max(1 + K, b))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
k, a, b = (int(x) for x in input().split())
if b - a <= 1 or k <= a: print(1+k)
else:
    k -= a - 1
    div_2 = k // 2
    m = k % 2
    print((b - a) * div_2 + m + a)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
K,A,B=map(int,input().split())
ans=0
if B-A<=2 or K+1<=A: #ぼったくり
  ans=K+1
else: #notぼったくり
  # A-1回ポケット叩いてA個のビスケットを用意する。A-1/Kつかう
  # B枚に交換してBの方が大きいので交換し続ける。それぞれ2/Kつかう
  # 最後に1回あまればビスケットを1枚増やしとく。1/Kつかう
  t=(K-A+1)//2 #交換する回数
  ans=B*t-A*(t-1)+(K-A+1)%2
print(ans)

Submission status: Accepted

Solution code:
import copy
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement
from math import floor, ceil, sqrt, factorial, log
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict
from heapq import heappop, heappush, heappushpop
from itertools import product
import sys
stdin = sys.stdin
mod = 10**9 + 7


def ns(): return stdin.readline().rstrip()


def ni(): return int(ns())


def na(): return list(map(int, stdin.readline().split()))


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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

rem = K-(A-1)
if rem <= 1:
    print(ans)
else:
    ans2 = A
    d,m = divmod(rem,2)
    ans2 += (B-A)*d
    ans2 += m
    print(max(ans, ans2))

Submission status: Accepted

Solution code:
K,A,B=map(int, input().split())
ans=K+1
if A<B and K>=A:
    n=K-A+1
    ans=max(ans, A+n//2*(B-A)+(n&1))
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:
    print((k-a+1)//2*(b-a)+(k-a+1)%2+a)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

if B - A <= 2:
    print(1+K)
else:
    if A - 1 >= K:
        print(1+K)
    else:
        k = K - (A-1)
        ans = A + (k // 2) * (B-A) + (k&1)
        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:
    k -= a - 1
    times = k // 2
    print(a + (b - a) * times + k % 2)

Submission status: Accepted

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

ans = 1
if B > A + 2:
    # まずB枚生成
    ans += B - 1
    K -= A + 1
    # 2動作ごとにB-A増える
    n = K // 2
    ans += n * (B - A)
    # 1回操作余ってたら足す
    ans += K % 2
else:
    ans += K

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    K, A, B = (int(i) for i in input().split())
    ans = 1
    K -= (A-ans)
    ans = A
    if B-A > 2:
        ans += (B-A)*(K // 2)
        if K & 1:
            ans += 1
    else:
        ans += 1*K
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
''' Hey stalker :) '''
INF = 10**10
def main():
    print = out.append
    ''' Cook your dish here! '''
    k, a, b = get_list()
    if 2+a>b or k<a:
        print(k+1)
    else:
        k -= a-1
        bis = a + (k//2)*(b-a) + k%2
        print(bis)



''' Pythonista fLite 1.1 '''
import sys
from collections import defaultdict, Counter
from bisect import bisect_left, bisect_right
#from functools import reduce
import math
#input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
out = []
get_int = lambda: int(input())
get_list = lambda: list(map(int, input().split()))
main()
#[main() for _ in range(int(input()))]
print(*out, sep='\n')

Submission status: Accepted

Solution code:
"""
NTC here
"""
import sys
inp= sys.stdin.readline
input = lambda : inp().strip()
flush= sys.stdout.flush
# import threading
# setrecursionlimit(10**6)
# threading.stack_size(2**26)

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

# range = xrange
# input = raw_input

def main():
    k, a, b = lin()
    ans = 1
    lf = max(0, k - a+1)
    lf1 = lf//2
    if lf:
        ans = a+lf1*(b - a) + lf%2
    else:
        ans += k
    print(max(ans, k+1))








        
main()
#threading.Thread(target=main).start()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def examA():
    N, K = LI()
    if (N+1)//2>=K:
        print("YES")
    else:
        print("NO")
    return

def examB():
    d = [0]*4
    for _ in range(3):
        a, b = LI()
        a -=1; b -=1
        d[a] +=1
        d[b] +=1
    for i in d:
        if i>=3 or i==0:
            print("NO")
            return
    print("YES")
    return

def examC():
    K, A, B = LI()
    if A+1>=B:
        ans = K+1
        print(ans)
        return
    l = 0; r = K+1
    while(r-l>1):
        # 何回換金できるか
        now = (l+r)//2
        cur = K - now +1
        if cur<A:
            r = now
        else:
            l = now
    ans = K - l + (l//2)*(B-A) +1 + l%2
    print(ans)
    return
def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LFI(): return list(map(float,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
alphabet = [chr(ord('a') + i) for i in range(26)]

if __name__ == '__main__':
    examC()

"""

"""

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# C - When I hit my pocket...

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

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

Submission status: Accepted

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

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

k-=a-1
sm=a
num=int(k/2)
sm += num*(b-a)

if k%2==1:
    sm+=1

print(sm)

Submission status: Accepted

Solution code:
K, A, B = map(int, input().split())
 
ans = 1
if A + 1 >= B  or A >= K:
    ans += K
else:
    # ビスケットがA がたまるまでの操作回数
    K -= A - 1
    # A枚→1円→B枚で2回操作
    r = K // 2
    m = K % 2
    ans = A +  r * (B - A) + m
 
print(ans)

Submission status: Accepted

Solution code:
K, A, B = map(int, input().split())
if B-A > 2:
    tmp = max((K-A+1)//2, 0)    # Bの回数
    ans = 1 + tmp * (B-A) + (K-tmp*2)
else:
    ans = 1 + K
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

ans = 1
if A + 1 >= B  or A >= K:
    ans += K
else:
    # ビスケットがA がたまるまでの操作回数
    K -= A - 1
    # A枚→1円→B枚で2回操作
    r = K // 2
    m = K % 2
    ans = A +  r * (B - A) + m

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# 何回目のアタックだよこれ（前回までのは当然読んですら無い）
# 単純にa<bのとき貯めれるだけためて残りをbにぶっこむのじゃ駄目なの?
k, a, b = map(int, input().split())
if a >= b or b - a <= 2:
    # 貯めるだけムダなので全振り
    print(1 + k)
    exit()
x = a  # はじめてa枚貯まってから1円に交換したターン
d = k - x  # x時点での残りターン

if d % 2 == 0:
    # 直前で止めて+1したほうがいい
    print(a + (b - a) * (d // 2) + 1)
else:
    # そのまま交換したほうがいい
    print(b + (b - a) * (d // 2))

Submission status: Accepted

Solution code:
# 何回目のアタックだよこれ（前回までのは当然読んですら無い）
# 単純にa<bのとき貯めれるだけためて残りをbにぶっこむのじゃ駄目なの?
k, a, b = map(int, input().split())
if a >= b or b - a <= 2:
    # 貯めるだけムダなので全振り
    print(1 + k)
    exit()
x = a  # はじめてa枚貯まってから1円に交換したターン
d = k - x  # x時点での残りターン

if d == 0:
    # 変えないほうがよかったね
    print(1 + k)
    exit()
if d % 2 == 0:
    # 直前で止めて+1したほうがいい
    print(a + (b - a) * (d // 2) + 1)
else:
    # そのまま交換したほうがいい
    print(b + (b - a) * (d // 2))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def main():
    K,A,B = map(int,input().split())
    if B-A<=2:
        print(1+K)
        exit()
    now = 1
    K -= (A-1)
    now = A
    if K%2==0:
        now += (B-A)*(K//2)
    else:
        now += (B-A)*((K-1)//2)
        now += 1
    print(now)  
if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

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

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


print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

max_change = max(0, (k - (a - 1)) // 2)
print(max(k+1, 1+k-max_change*2 + (b-a)*max_change))

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


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


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(K, A, B)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

K += 1

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:

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

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

else:

    ans = A
    K -= A-1

    if K % 2 == 1:
        ans += 1
        K -= 1

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

    print (ans)

Submission status: Accepted

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

if B-A<=1:
    print(K+1)
else:
    if 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())
print(max(k+1,a+(k-a+1)//2*(b-a)+(k-a+1)%2))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import bisect
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


K, A, B = list(map(int, sys.stdin.buffer.readline().split()))

count = 1

# A になるまで増やす
count += min(K, A - 1)
K -= min(K, A - 1)

if K % 2 == 1:
    count += 1
    K -= 1

# いっぱい増える方法をいっぱいやる
if - A + B > 2:
    count += (- A + B) * K // 2
else:
    count += K
print(count)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin
K, A, B = [int(_) for _ in stdin.readline().rstrip().split()]
if K < A-1 or B-A <= 2:
    print(K+1)
else:
    ans = A
    K -= A-1
    if K % 2 == 1:
        ans += 1
        K -= 1
    ans += (B-A)*(K//2)
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
K,A,B=map(int,input().split())
ans=1
if B-A<=2: # 日本円を経由してビスケットを増やせない場合 ※B-A==2であれば，操作2回で日本円を経由するのと，ビスケットを2回叩くのが等価。
    ans+=K
else: # 日本円を経由してビスケットを増やせ得る場合
    if A>1 and A-1<=K: # 日本円に交換するためにビスケットを叩く必要があり，かつ，日本円に交換できるだけのビスケットを得られる場合には，まず，日本円に交換できるだけのビスケットを作る。
        ans=A
        K-=A-1    
    # （最後に回してもよいが，便宜上ここで）残り操作回数が奇数であれば，1回ビスケットを叩いておく。
    if K%2==1:
        ans+=1
        K-=1
    # 以下，日本円を経由する2回の操作でビスケットを(B-A)枚増やせる。
    ans+=(B-A)*(K//2)
    K=0 # 一応
    
print(ans)

Submission status: Accepted

Solution code:
# C - When I hit my pocket...
k,a,b = map(int,input().split())

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush, heapify
import math
import itertools
import random

import os
 
# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
INF = float('inf')
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    K,A,B = inputMap()
    
    if A+2 >= B:
        print(1+K)
        sys.exit()
        
    sai = A+1
    ans = 1
    if K < sai:
        print(1+K)
        sys.exit()
        
    else:
        sai = A-1
        K = K-sai
        
        if K % 2 == 1:
            K -= 1
            ans = 1
            kai = int(K / 2)
            ans += (B-A)*kai
            ans += A
            
        else:
            kai = int(K / 2)
            ans = (B-A)*kai
            ans += A
        
    print(ans)
    #print(48518828981938099)
    
    
if __name__ == "__main__":
	main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
k, a, b = map(int, input().split())
q, r = divmod(k - a + 1, 2)
print(max(k + 1, a + q * (b - a) + r))

Submission status: Accepted

Solution code:
from sys import stdin

k,a,b = [int(x) for x in stdin.readline().rstrip().split()]

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

maisu = a
kaisu = a-1

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

print(maisu)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# 1回で+1 か2回でA枚-> Bのどちらか
# B / A > 2 なら、可能な限りAB変換して余りの回数を+1
K, A, B = map(int, input().split())

ans = 1

# まずは A枚ビスケットを作る
if K > A - 1:
  ans += A - 1
  K -= A - 1
else:
  print(ans + K)
  exit()

# B - A > 2なら変換。  
if B - A > 2:
  d, m = divmod(K, 2)
  ans += d * (B - A) + m
else:
  ans += K
print(ans)

Submission status: Accepted

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

if b-a <=  2:
    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())
 
ans = K+1
if A+2 >= B:
    print(ans)
    exit()
 
K -= (A-1)
if K < 0:
    print(ans)
    exit()
 
b = A
b += (K//2) * (B-A)
b += K%2
print(max(ans, b))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
K, A, B = map(int, input().split())
answer = 1
if B - A <= 2:
    #ずっと＋１する場合
    answer += K
else:
    time = A - 1 #A枚最初に手に入る
    if time + 2 > K or B - A < 2:
        answer += K
    else:
        answer += time
        q, mod = divmod(K-time, 2)
        answer += q * (B-A)
        answer += mod
print(answer)

Submission status: Accepted

Solution code:
K, A, B = map(int, input().split())
answer = 1
if B - A <= 2:
    #ずっと＋１する場合
    answer += K
else:
    time = A - 1 #A枚最初に手に入る
    if time + 2 > K or B - A < 2:
        answer += K
    else:
        answer += time
        answer += ((K-time)//2) * (B-A)
        answer += (K-time)%2
print(answer)

Submission status: Accepted

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

S=K+1
diff=B-A
t=((K-A+1)//2)
T=diff*t
odd=((K-A+1)%2)
print(max(T+odd+A,S))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

# 最初にaが貯まるまで: はじめに1を持っているので、
x = a - 1

# 残りの回数
y = k - x

iteration, res = divmod(y, 2)

print(max(a + iteration*(b-a) + res, k+1))

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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