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: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

num=1
coin=0
for i in range(K):
  if(num==A):
    coin+=1
    num=0
  elif(coin>0):
    num=num+(coin*B)
    coin=0
  else:
    num+=1
num_a=1+K
if(num_a>num):
  print(num_a)
else:
  print(num)

Submission status: Time Limit Exceeded

Solution code:
K, A, B = map(int, input().split())
if A >= B-2:
    print(K+1)
else:
    nowb = 1
    nowm = 0
    for i in range(K):
        if nowm == 1:
            nowb += B
            nowm -= 1
        elif nowb >= A and i < K-1:
            nowb -= A
            nowm += 1
        else:
            nowb += 1
    print(nowb)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

if a + 3 <= b:
    x = 0
    k -= (a+2)
    x += b

    n, res = divmod(k, 2)
    x += (b-a)*n+res
    print(x)
else:
    print(k)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def main():
    k, a, b = input_list()

    # たたきルート１手１枚増える
    # 交換ルートは2手必要
    if b - a > 2:
        # bisketをA枚にする
        bis = a
        k -= a - 1
        
        if k % 2 == 1:
            bis += 1
            k -= 1
        bis += (k//2) * (b-a)
        print(bis)
    else:
        print(k+1)

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

if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# import sys
# input = sys.stdin.readline
# import re
import collections
import bisect
import math
import fractions
import collections
import itertools
from functools import reduce

def main():
    k, a, b = input_list()
    if b - a > 2:
        bis = a
        k -= a - 1
        if k % 2 == 1:
            bis += 1
            k -= 1
        bis += (k//2)*(b-a)
        print(bis)
    else:
        print(k+1)


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

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

Submission status: Accepted

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

if a + 2 >= 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())

num=b-a
ans=0

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right #func(リスト,値)
from heapq import heapify, heappop, heappush
from math import *

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)

K,A,B = mint()

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys, math
from functools import lru_cache
from collections import defaultdict, Counter
import bisect
sys.setrecursionlimit(10**9)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

def main():
    K, A, B = mi()

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

    x = max(0, (K-(A-1))//2)
    y = K-2*x

    print((B-A)*x+y+1)
    

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def cin():  return list(map(int,input().split()))
K, A, B = cin()
ans1 = K + 1
kk = K - (A - 1)
ans2 = 0
if kk > 0:
    if kk % 2:  ans2 = A + 1 + kk // 2 * (B - A)
    else:  ans2 = A + kk // 2 * (B - A)
ans = max(ans1, ans2)
print(ans)

Submission status: Accepted

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

if a+1<b:
    ans=0
    if k<=a:
        ans=k+1
    else:
        ans=(a-1)+1
        k-=(a-1)
        if k%2==0:
            #print("even")
            ans+=(k//2)*(b-a)
        else:
            #print("odd")
            ans+=(k//2)*(b-a)+1


    print(ans)


else:
    print(1+k)

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    K, A, B = [int(x) for x in input().split()]

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
#39 C - When I hit my pocket...
K,A,B = map(int,input().split())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def f(k,a,b,t):
	if k == 0:
		return t
	

	if t >= a:
		if b-a > 2 and k >= 2:
			return f(k%2, a,b,t + k/2 * (b-a))
		else:
			return f(0, a, b, t + k)
	else:
		dist=  a-t
		return f(k-min(k,dist), a, b, t + min(k,dist))

k,a,b = map(int, raw_input().split())
print f(k,a,b,1)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
# from math import ceil, floor, log2
# from collections import deque, defaultdict
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np    # cumsum
# from bisect import bisect_left, bisect_right

def solve():
    K, A, B = MI()

    ans = 1
    if (B-A) <= 2:
        ans += K
    else:
        sa = A - ans
        K -= sa
        ans = A
        p, q = K // 2, K % 2
        ans += (B-A) * p + q
    print(ans)


if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

k,a,b=nii()

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

if num<a:
  k-=a-num
  num+=a-num

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

print(num)

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/yahoo-procon2019-qual/tasks/yahoo_procon2019_qual_c
import sys
# sys.setrecursionlimit(100000)


def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    k, a, b = input_int_list()
    if b - a <= 2:  # 2ターン 使って、作れるビスケットが2個以下だと最大化しない。
        ans = k + 1
    else:
        exchange, mod = divmod((k - (a - 1)), 2)
        ans = a
        ans += exchange * (b - a)
        ans += mod
    print(ans)

    return


if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
def MI(): return map(int,sys.stdin.readline().rstrip().split())

K,A,B = MI()

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

Submission status: Accepted

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


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


print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

if k-(a-1)<=0:
  print(k+1)
  exit()
  
  
ans=k+1
k-=(a-1)
# now=a個
now=a
if k%2==1:
  now+=1
  k-=1
now=now+(b-a)*(k//2)
ans=max(now,ans)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

K, A, B = mapint()
if (B-A)/2<=1:
    print(K+1)
else:
    cnt = A
    rest = K - cnt + 1
    if rest<2:
        print(K+1)
    else:
        if rest%2==0:
            print(cnt+(B-A)*rest//2)
        else:
            rest -= 1
            cnt += 1
            print(cnt+(B-A)*rest//2)

Submission status: Accepted

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

if K-1 < A:
  print(K+1)
  exit()
  
K -= (A-1)
num = K//2
nokori = K%2
#print(K,num,nokori)
ans = A+num*(B-A)+nokori
print(ans)

Submission status: Accepted

Solution code:
import sys

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

if K + 1 < A:
    print(K+1)
else:
    if A + 2 < B:
        # print("here")
        n = K - (A - 1)
        r = n // 2
        # print(n % 2)
        print(A + r * (B - A) + n % 2)
            
    else:
        print(K+1)

Submission status: Accepted

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

if a + 2 > b or k < a:
    print(k + 1)
else:
    k -= (a - 1)
    have = a
    div, mod = divmod(k, 2)
    print((b - a) * div + a + mod)

Submission status: Accepted

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

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

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

Submission status: Accepted

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


bisket=1

cnt=a-bisket

if cnt>k:
    print(1+k)
    exit(0)

k-=cnt
bisket+=cnt

if a+2<=b:
    trade=k//2
    k-=trade*2
    
    bisket+=trade*(b-a)

    if k==1:
        bisket+=1
    
    print(bisket)


else:
    print(bisket+k)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし

K,A,B = MI()

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

Submission status: Accepted

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

Submission status: Accepted

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

x = (K - (A - 1)) // 2 * (B - A) + A
if (K - (A - 1)) % 2 != 0:
    x += 1

print(max(x, K + 1))

Submission status: Accepted

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

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

x = (K - (A - 1)) // 2 * (B - A) + A
if (K - (A - 1)) % 2 != 0:
    x += 1

print(max(x, K + 1))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

else:
    K -= A - 1
    q, m = divmod(K, 2)
    print((B - A) * q + A + m)

Submission status: Accepted

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

Submission status: Accepted

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

if b-a<3:
    ans = k+1
else:
    if k<a+1:
        ans = k+1
    else:
        ope = k-(a-1)
        ope_ab = ope//2
        ans = ope_ab*b - (ope_ab-1)*a + ope % 2
        ans = int(ans)

print(ans)

Submission status: Accepted

Solution code:
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")

k, a, b = map(int, input().split())
k += 1
cnt =  k - (a + 2)

if b - a > 2 and cnt >= 0:
    ans = b + (b - a)*(cnt//2) + cnt%2
else:
    ans = k

print(ans)

Submission status: Accepted

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

if b - a > 2 and cnt >= 0:
    ans = b + (b - a)*(cnt//2) + cnt%2
else:
    ans = k

print(ans)

Submission status: Accepted

Solution code:
import sys
k,bisc_to_yen,yen_to_bisc = map(int,input().split())
if yen_to_bisc - bisc_to_yen <= 2 or k-1 < bisc_to_yen:# 後者は、「あと二回で終了」までに地道増やしが間に合わない場合
    print(k+1)
    sys.exit()
before_change = bisc_to_yen - 1
remain = k - before_change
num_change = remain//2
ans = num_change*(yen_to_bisc-bisc_to_yen)
if remain % 2 == 1:
    ans += 1
print(ans+bisc_to_yen)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

bisc = 1
yen = 0

ans = K + 1

if A >= B:
    print(ans)
    exit()

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

ans = 1
if b >= a+3:
    if k >= a+1:
        ans += b-1

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

print(ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
 
## Library
 
import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter
import itertools
import copy
 
## input
 
# N=int(input())
# A,B,C,D=map(int, input().split())
# S = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]
#    S = []
#    for _ in range(N):
#        S.append(list(input()))
 
K,A,B=map(int, input().split())

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

Submission status: Accepted

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

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

Submission status: Accepted

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

rate = (b-a)/2

if ( rate > 1):
    k-=(a-1)
    biscet+=(a-1)
    biscet += int(k/2) * (b-a)
    biscet += k%2
    
else:
    biscet += k    

print(biscet)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys,math,collections,itertools
input = sys.stdin.readline
cnt =1
K,A,B=list(map(int,input().split()))
if A+2<=B:#交換したほうがいい
    if A-1 >=K:#最低交換枚数に達しない
      cnt = 1+K
    else:
        cnt = A + (K-(A-1))//2*(B-A)+(K-(A-1))%2
else:
    cnt = 1+K
print(cnt)

Submission status: Accepted

Solution code:
import sys


INF = 10**60
inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instr = lambda: sys.stdin.readline()
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

k, a, b = inintm()
ans = 0

if a + 2 >= b:
    print(1+k)
else:
    ch = max(0, (k-(a-1))//2)
    print(b + (ch-1)*(b-a) + k-(ch*2+a-1))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

total = 1
cost = b/(a + 1)

if cost > 1:
    if k >= a - 1:
        n = (k - (a - 1)) // 2
        total += n * (b - a)
        total += k - 2 * n
    else:
        total += k
else:
    total += k

print(total)

Submission status: Accepted

Solution code:
#みんなのプロコン2019-C
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

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

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

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

ans = a+res*(b-a)

if not even(k-(a-1)):
    ans += 1

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

if k < a:
    ans = k + 1

else:
    if b <= a + 2:
        ans = k + 1

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

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