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:
# import bisect
# import heapq
# import math
# import random
# from fractions import gcd
# from collections import Counter, defaultdict, deque
from decimal import Decimal
import decimal
# from functools import lru_cache, reduce
# from itertools import combinations, combinations_with_replacement, product, permutations
# from operator import add, mul, sub, itemgetter
# import numpy as np

import sys
sys.setrecursionlimit(10000)

def read_int(read=None):
	if read == None:
		read = sys.stdin.readline().strip()
	return int(read)

def read_int_n(read=None):
	if read == None:
		read = sys.stdin.readline().strip()
	return [int(x) for x in read.split()]

def read_float(read=None):
	if read == None:
		read = sys.stdin.readline().strip()
	return float(read)

def read_float_n(read=None):
	if read == None:
		read = sys.stdin.readline().strip()
	return [float(x) for x in read.split()]

def read_str(read=None):
	if read == None:
		read = sys.stdin.readline().strip()
	return str(read)

def read_str_n(read=None):
	if read == None:
		read = sys.stdin.readline().strip()
	return [str(x) for x in read.split()]	
	
def error_print(*args):
	print(*args, file=sys.stderr)

def mt(f):
	import time
	def wrap(*args, **kwargs):
		s = time.time()
		ret = f(*args, **kwargs)
		e = time.time()
		error_print(e - s, 'sec')
		return ret
	return wrap

@mt
def slv(K, A, B):
	if B - A <= 2:
		ans = K + 1
	else:
		if (K - A + 1) % 2 ==0:
			ans = (B-A)*(Decimal(str(K-A+1))/Decimal('2'))+A
		else:
			ans = (B-A)*(Decimal(str(K-A))/Decimal('2'))+A+1
	return ans

def main():
	t = '''4 2 6'''.splitlines()
	K, A, B = read_int_n()
	print(slv(K, A, B))

if __name__ == '__main__':
	main()

Submission status: Accepted

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

def f(k,a,b):
    if b-a<=0:
        return k+1
    elif k+1<a:
        return k+1
    else:
        res1 = k+1
        res2 = b
        k -= 1+a
        # print(k,res2)
        if k>0:
            res2 += (b-a)*(k//2)
            res2 += k%2
        elif k<0:
            res2 = -1
        return max(res1, res2)

def f2(k,a,b):
    k_ = k
    res = 1
    while k>0 and res<a:
        res += 1
        k -= 1
    res += (b-a)*(k//2)
    res += k%2
    return max(res, k_+1)

if __name__ == '__main__':
    k,a,b = map(int, input().split())
    print(f(k,a,b))

    # print(f(3,3,5))
    # from random import randint
    # for _ in range(1000):
    #     k = randint(1,100)
    #     a = randint(1,100)
    #     b = randint(1,100)
    #     res1 = f(k,a,b)
    #     res2 = f2(k,a,b)
    #     if res1!=res2:
    #         print(k,a,b)
    #         print(res1,res2)
    #         break

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

bsc=1
if b-a<=2:
    bsc+=k
elif a-1>=k:
    bsc+=k

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

print(bsc)

Submission status: Accepted

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

answer = 1

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

print(answer)

Submission status: Accepted

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


main()

Submission status: Accepted

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

ans = 0
if a >= b:
    ans = 1+k
elif a+2 <= b:
    k=k-(a-1) #1の操作を行う
    if k%2==0:
        ans = a + (k//2)*(b-a)
    else:
        ans = a + (k//2)*(b-a) + 1
else:

    ans = 1+k


print(ans)

Submission status: Accepted

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

twoans = A
now = A-1
if A*2 < B:
    while now < K:
        if now + twoans//A*2 <= K:
            now += twoans//A*2
            twoans = twoans - (twoans//A*A) + (twoans//A*B)
        else:
            break
if (K - now)%2 == 0:
    twoans = twoans + (K-now)//2*(B-A)
else:
    twoans = twoans + (K-now)//2*(B-A)+1
print( max(twoans,  ans, K+1))

Submission status: Accepted

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

  K -= A - 1
  mod = K % 2
  N = K // 2
  return A + (B - A) * N + mod

print(solve())

Submission status: Accepted

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

def f():
    # A枚に達する
    a = A - 1
    # 増殖に使える時間
    b = K - a
    # A->Bにd回変換
    d, m = divmod(b, 2)
    return A + (B - A) * d + m

def g():
    return 1 + K

if (A + 2) < B:
    print(f())
else:
    print(g())

Submission status: Accepted

Solution code:
import sys,collections,math;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

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

Submission status: Accepted

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

if a + 2 <= b and k + 3 > a:
    k -= a - 1
    n = k // 2
    x = (b - a) * n + a
    y = k % 2
    print(x + y)

else:
    print(1 + k)

Submission status: Accepted

Solution code:
from statistics import mean, median,variance,stdev
import sys
import math
import fractions

def j(q):
    if q==1: print("YES")
    else:print("NO")
    exit(0)


def ct(x,y):
    if (x>y):print("")
    elif (x<y): print("")
    else: print("")

def ip():
    return int(input())

#n = ip()                              #入力整数1つ
#x,y= (int(i) for i in input().split())      #入力整数横2つ
k,a,b = (int(i) for i in input().split())    #入力整数横3つ
#n,m,x,y= (int(i) for i in input().split())  #入力整数横4つ
#a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列

#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
left = 0
s = 0
if a >= b or a+1==b or k<=a:
    print(k+1)
else :
    left  = k-a-1
    s+=b
    s+= (left//2)*(b-a)
    if left%2 :s+=1
    print(s)

Submission status: Accepted

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

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


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


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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    k, a, b = map(int, raw_input().split())
    biscuit = 1
    mon = 0
    if b - a <= 2:
        print 1 + k
        return
    if biscuit < a:
        if k < a - biscuit:
            print 1 + k
            return
        k -= a - biscuit
        biscuit = a
    print biscuit + (b - a) * (k / 2) + k % 2


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools


sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]


def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    K, A, B = LI()
    result = 0
    # 交換する価値もない
    if A >= B - 1:
        # 割りまくる
        result = K + 1
        print(result)
        return

    # 交換をできるだけする
    # 最初に円にできるまでにどれだけかかるか？？
    times_to_first_yen = A - 1
    # K - times_to_first_yenはひたすら交換しまくる
    remaining_times = K - times_to_first_yen
    result += (remaining_times // 2) * (B - A) + A
    # 端数の処理をする
    if remaining_times % 2 != 0:
        result += 1

    print(result)


main()

Submission status: Accepted

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

Submission status: Accepted

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

import sys

i_str = input().split(' ')
k = int(i_str[0])
a = int(i_str[1])
b = int(i_str[2])

#print(k, a, b)

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

Submission status: Accepted

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

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

Submission status: Accepted

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

print(max(k+1, q*(b-a)+a+r))

Submission status: Accepted

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

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

if K == 1:
    print(2)
elif B - A < 3:
    # 2回かけるので3以上増えないと意味ない
    print(1+K)
else:
    # b < Aまでは+1で増やす (A-1回)
    # b >= Aなら2回で-A+B増やす

    # -A+Bを行える回数を調べる
    d = K - A + 1
    if d % 2 == 0:
        res = A + (d//2)*(B-A)
    else:
        res = A+1 + (d//2)*(B-A)

    print(res)

Submission status: Accepted

Solution code:
def func(K , A , B) : 
    if B >= A + 3 :
        if (K - A + 1) % 2 == 0 : 
            n = int((K - A + 1) / 2)
            return n * (B - A) + A 
        else : 
            n = int((K - A) / 2)
            return n*(B - A) + A + 1
    else : 
        return K + 1


s = input().split(" ")
print( int(func( int(s[0]) , int(s[1]) , int(s[2]) )) )

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
K, A, B = map(int,input().split())
if A + 2 >= B:
    ans = K + 1
elif K <= A:
    ans = K + 1
else:
    # A-1回たたく
    time = K - (A-1)
    ans = A 
    # n回 A枚をBに交換する 2*n回数分の操作
    n = time // 2
    mod = time % 2
    ans += n*(-A + B)
    ans += mod

print(ans)

Submission status: Accepted

Solution code:
import sys

def main():
  input = sys.stdin.readline
  K, A, B = map(int, input().split())

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


if __name__ == '__main__':
  main()

Submission status: Accepted

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

# 全部でK回
# 1枚からA枚に行くまでにA-1回
# 残りK-A+1回
# そこから2回でB-A枚増える
# 2で割り切れないときは、＋1する

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

if b < K + 1:
    b = K + 1
print(b)

Submission status: Accepted

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

  if ((B-A) <= 2):
    print(str(K+1))
    return
  
  if (K < (A - 1 + 2)):
    print(str(K+1))
    return
  
  r = K - (A - 1)
  a = r // 2
  b = r % 2

  print(a*(B-A) + A + b)

main()

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def m():
    K, A, B = map(int, input().split())
    ans = 0
    if B - A <= 2:
        return K+1
    if K <= A:
        return K+1
    cnt = K-A+1

    amari = 0
    if cnt % 2 == 1:
        amari = 1
    ans += (cnt//2) * B - ((cnt//2)-1)*A
    ans += amari
    return ans

print(m())

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

    count = (B-A) * (K//2) + (K % 2) + A

    print(count)

Submission status: Accepted

Solution code:
import sys
import numpy as np

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

Submission status: Accepted

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

if A + 1 >= B:
    ans = K + 1
else:
    rem = K - (A - 1)
    double = rem // 2
    remrem = rem - double * 2
    ans = B + (double - 1) * (B - A) + remrem
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
K, A, B = map(int,input().split())
if B-A <=2:
    ans = K + 1
elif K <= A:
    ans = K +1
else:
    # A-1回たたく
    time = K - (A-1)
    ans = A 
    # n回 A枚をBに交換する 2*n回数分の操作
    n = time // 2
    mod = time % 2
    ans += n*(-A + B)
    ans += mod

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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

	n = 1

	if a > k - 1:
		print(n + k)
		return

	n += a - 1
	k -= a - 1

	#print(n, k, a, b)
	if b - a >= 2 and k >= 2:
		n += (b - a) * (k // 2) + k % 2
	else:
		n += k

	print(n)


if __name__ == '__main__':
	main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!venv/bin/python

import math

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

num = 1
money = 0


if B - A <= 2:
    num += K
else:
    turn = K
    turn -= (A - num)
    num = A
    if turn % 2 == 0:
        add = (B - A) * int((turn / 2))
        num += add
    else:
        num += (B - A) * int(math.floor(turn / 2))
        num += 1
print(int(num))

Submission status: Accepted

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

cur = 1

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

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

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

print(res)

Submission status: Accepted

Solution code:
import sys

k,a,b = [int(x) for x in input().split()]

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

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

Submission status: Accepted

Solution code:
def func(k, a, b):
    if b > a + 2 and k >= a - 1:
            print(a + (b - a) * ((k - a + 1) // 2)
                  + (k - a + 1) % 2)
    else:
        print(1 + k)
#func(4, 2, 6)
#func(7, 3, 4)
#func(314159265, 35897932, 384626433)
k, a, b = [int(i) for i in input().split()]
func(k, a, b)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8

line=input().split()
K=int(line[0])
A=int(line[1])
B=int(line[2])

b_rate=B-A

i=0

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

sum=A
K-=A-1

if b_rate>2 and K>=2:
    sum+=K//2*b_rate
    if K%2==1:
        sum+=1
else:
    sum+=K
print(sum)

Submission status: Accepted

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

Submission status: Accepted

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

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

diff = b - a
k -= a + 1
n = k // 2
rest = k % 2
if n == 0:
    print(b + rest)
    exit()
print(b + n * diff + rest)

Submission status: Accepted

Solution code:

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


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

else: 
    tap = a-1

    remK = k-tap

#    print('remK = {}'.format(remK) )
    ans = a
    ans += (remK // 2) *( b-a ) + remK % 2
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding:utf-8 -*-
import sys
import functools

K, a, b = list(map(int, input().split()))

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

        # ビスケット A 枚
        if b - a > 2:
            # ひたすら交換する
            print((k // 2) * b - (k // 2 - 1) * a + (k % 2))            
        else:
            # ひたすら叩く
            print(K + 1)
    else:
        print(K + 1)

Submission status: Accepted

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

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

ans = 1
if b - a <= 2:
    # No Exchange
    ans += k
elif k < (a - 1) + 2:
    # cannot do first exchange
    ans += k
else:
    k -= (a - 1) + 2
    ans = b
    ans += (b - a) * int(k / 2)
    if k % 2 == 1:
        ans += 1

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
K,A,B = [int(i) for i in input().split()]
if A >= B - 1:
    print(K+1)
else:
    ans = 0
    count = (K+1-A)//2
    amari = (K+1-A)%2
    ans += count*(B-A)
    ans += amari
    ans += A
    print(ans)

Submission status: Accepted

Solution code:
import math

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


if(b>a+2):

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

if a >= b:
    print(1+k)
else:
    p1 = [1,1]
    p2 = [b-a,2]
    proc = [p1,p2]
    proc.sort(key=lambda x:x[0]/x[1])
    proc.reverse()
    if proc[0] == p1:
        print(1+k)
    elif proc[0] == p2:
        if a-1 > k:
            print(1+k)
        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 a>=b-2 or a >= k:
  print(k+1)


else: 
  tataku = (a-1)
  nokori = k-(a-1)
  koukan_times = nokori//2

  bisuket = a + (b-a)*koukan_times

  if nokori%2 == 1:
    print(bisuket+1)
  else:
    print(bisuket)

Submission status: Accepted

Solution code:

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

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

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

    ans = B
    k = K - (A + 1)

    ans += (k // 2) * (B - A) + (k % 2)

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

if B - A <= 1:
  print(1+K)
else:
  remainK = K - (A - 1)
  current = A

  if remainK % 2 == 1:
    remainK -= 1
    current += 1

  t = int(remainK / 2) * int(B-A)
  print(int(current + t))

Submission status: Accepted

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

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

ans = a
k -= a - 1

ans += k % 2

ans += (b - a) * (k // 2)

print(ans)

Submission status: Accepted

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

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

ans = 1
ans += A-1
K -= A-1
if K & 1 == 1:
    ans += 1
    K -= 1

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sat Feb  9 20:33:17 2019

@author: Yamazaki Kenichi
"""

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

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

Submission status: Accepted

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

Submission status: Accepted

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



k-=a-1
ko=k//2
#print(ko)
print(max(ko*(b-a)+a+k%2,kk+1))

Submission status: Accepted

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

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

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

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(mi())

k, a, b = mi()
ans1 = k + 1
ans2 = 0
if b > a and k > a - 1:
    k -= a - 1
    ans2 = a + (k // 2) * (b - a) + k % 2
print(max(ans1, ans2))

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

if A <= B - 3:
   if A - now + 2 <= K:

        K -= (A - now + 2)
        now = B

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

   else:
       now += K
       #A, Bの動作に到達するまえにKが尽きてしまうので+= 1


else:
    now += K

    #そもそもA、Bの動作をやるだけ損なのでひたすら+=1

print(now)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from functools import lru_cache, reduce
from math import ceil, floor

import heapq
import itertools
import operator


def get_int():
    return int(input())


def get_str():
    return input().strip()


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


def get_char_list():
    return list(input().strip())


def main():
    k, a, b = get_int_list()
    if b - a < 2:
        print(1 + k)
        return
    print(a + ((k - (a - 1)) // 2) * (b - a) + ((k - (a - 1)) % 2))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import math
import sys
from operator import itemgetter

# N, K = map(int, input().split())
# h = list(map(int, input().split()))
# S = [input() for _ in range(H)]
# X = [[0 for j in range(100)] for i in range(200)]

# if __name__ == '__main__':


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

ans = 1
## a枚に達するまでは+1
ans += a - 1
k = k - ans + 1

## b-a >= 2 ならば exchange法
if (b - a >= 2):
	if (k % 2 == 1):
		ans += (k//2) * (b - a) + 1
	else:
		ans += (k//2) * (b - a)
else:
	ans += k

print(ans)