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

Submission status: Accepted

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

#(方針) ビスケットの増やし方(B>A) 
#1:1回の操作で手持ちを1枚増やす(1回の操作で+1枚）
#2:2回の操作で手持ちのA枚をB枚にする(2回の操作で+3以上なら上よりお得）

ans = 0
if((B<=A+2)or(K<=A)): ans += K+1
else:
  count = A-1
  ans += A  #手持ちをA枚に
  #A枚をB枚にをできるだけ繰り返す
  if((K-count)%2 == 0):
   ans += (B-A)*((K-count)//2)
  else:
   ans += (B-A)*((K-count)//2) + 1
ans = max(K+1,ans)
print(ans)

Submission status: Accepted

Solution code:
def solve(k, a, b):
    if b - a > 2:
        t = k - a + 1
        if t % 2 == 0:
            c = (b-a) * (t // 2)
            c += a
        else:
            c = (b-a) * (t // 2)
            c += a + 1
        return max(k+1, c)
    else:
        return k+1

assert solve(4,2,6) == 7
assert solve(7,3,4) == 8
assert solve(314159265, 35897932, 384626433) == 48518828981938099

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

Submission status: Accepted

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

d = k - a + 1

if d >= 0:
    if b-a >= 2:
        step = b-a
    else:
        step = 2

ans = 1 

if d % 2 == 0:
    ans += d//2 * step + a - 1
else:
    ans += d//2 * step + a

print(ans)

Submission status: Accepted

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

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

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

Submission status: Accepted

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


if __name__ == "__main__":
    resolve()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# yahoo-procon2019-qualC - When I hit my pocket...
def main():
    K, A, B = map(int, open(0).read().split())
    if B - A <= 2 or K < A - 1:  # corner case
        print(K + 1)
        return
    ans, K = A, K - (A - 1)
    if K % 2:
        K -= 1
        ans += 1
    ans += (B - A) * K // 2
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def main():

    K, A, B = map(int, input().split())
    if B <= A:
        return K+1
    else:
        if A-1 >= K:
            return K+1
        else:
            L = K - (A-1) # A-1 times
            v = A
            v += (B-A) * (L // 2)
            if L % 2 == 1:
                v += 1
            return max(v, K+1)


if __name__ == '__main__':
    print(main())

Submission status: Accepted

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

Submission status: Accepted

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


if B - A <= 2:
    print(K + 1)
else:
    # 最初の交換まで叩く
    K -= (A - 1)

    # 1円->B枚に
    K -= 2
    ans = B

    # できるだけ交換
    ans += (B - A) * (K // 2)
    K %= 2

    # 最後に１回余れば叩く
    ans += K % 2

    print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter,defaultdict
import sys,bisect,math,itertools,string,queue
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

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

Submission status: Accepted

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

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


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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
K, A, B = [int(i) for i in 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)

Submission status: Accepted

Solution code:
def main():
  [k,a,b]=[int(x) for x in input().split()]
  
  if b-a<=2:
    print(k+1)
    exit()
  res=0
  while k>a:
    k-=2
    res+=b-a
  print(res+k+1)

if __name__ == '__main__':
  main()

Submission status: Accepted

Solution code:
import sys
def main():
    def input():
        return sys.stdin.readline()[:-1]
    K, A, B = map(int,input().split())
    if A+2 >= B:
        print(K+1)
    else:
        t = (K-A+1)//2
        if (K-A+1)%2 == 0:
            print(max(K+1, A+(B-A)*t))
        else:
            print(max(K+1, 1+A+(B-A)*t))

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())


k, a, b = li()

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

Submission status: Accepted

Solution code:
from sys import stdin
K,A,B=[int(x) for x in stdin.readline().rstrip().split()]

ans1 = K + 1
ans2 = 0

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

Submission status: Accepted

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

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

Submission status: Accepted

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


def intelliegnt():
    if b > a + 2 and k > a - 1:
        kk = k
        kk -= a - 1
        print(a + ((b - a) * (kk // 2)) + kk % 2)

    else:
        print(1 + k)


def greedy():
    biscuit = 1
    yen = 0

    for i in range(k):
        if yen > 0:
            yen -= 1
            biscuit += b
        elif b > a + 2 and biscuit >= a and (k - i) > 1:
            biscuit -= a
            yen += 1
        else:
            biscuit += 1

    print(biscuit)


if __name__ == "__main__":
    intelliegnt()

Submission status: Accepted

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

ans_1 = k+1
t = k - a + 1

ans_2 = (b-a)*(t//2) + a + (t%2) 
print(max(ans_1,ans_2))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
#みんなのプロコン2019 C

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10000000)
def input():
    return sys.stdin.readline()[:-1]
from bisect import *
from collections import *
from heapq import *
from math import *
from fractions import Fraction

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

Submission status: Accepted

Solution code:
K,A,B=map(int,input().split())
num=1
count=0
num+=A-1
count+=A-1
if B-A>=2:
  val=(K-count)//2
  num+=val*(B-A)
  count+=2*val

if count!=K:
  val2=K-count
  num+=val2
  count+=val2
print(num)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

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

change = (B - A) > 2

bisket = 1
t = min(A-1,K)
bisket += t
K -= t
if not change:
    bisket += K
else:
    q,r = divmod(K,2)
    bisket += (B-A) * q + r

print(bisket)

Submission status: Accepted

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

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)
    # print(m, B-A)
    ans = m * (B-A) + K - m * 2 + 1
    print(ans)

Submission status: Accepted

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

K -= A - 1 #ビスケットの枚数がA枚になるまでにする操作回数を引く
# print ('残り操作回数', K)
if K % 2 == 0: #残りの回数が偶数回 --> ビスケット --> お金 --> ビスケット　をK/2サイクル行う
    print (A + (B - A) * (K // 2))
else:
    print (A + (B - A) * (K // 2) + 1)

Submission status: Accepted

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

ans = 0
if A >= B:
    ans = K + 1
else:
    if K < A + 1:
        ans = K + 1 # ビスケットから円に替えるだけの試行回数がそもそもない場合叩き続ける
    elif K == A + 1:
        if A+2 > B:
            ans = A+2
        else:
            ans = B
    else:
        K -= A+1
        #この時点でA+2orB枚のビスケット
        if K // 2 == 0:
            ans = max(A+2, B) + 1
        else:
            if B - A > 2:
                ans = max(A+2, B) + (K//2)*(B-A) + K%2
            else:
                ans = max(A+2, B) + K

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
k,a,b=map(int,input().split())
if a>=b-2 or a>=k+1:
    print(k+1);exit()
#とりあえずビスケットをA枚まで増やす
bis=a
t=k-(a-1)#残り行動可能回数
#2回行動することによりビスケットはB-A枚増える
bis+=(t//2)*(b-a)
t-=(t//2)*2
#行動回数が1回残っていれば最後にビスケットを1枚増やす
bis+=t
print(bis)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# yahoo-procon2019-qualC - When I hit my pocket...
def main():
    k, a, b = list(map(int, input().rstrip().split()))
    if b - a <= 2 or k < a - 1:
        print(k + 1)
        return

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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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

    cockie = 1
    i = 0
    while i < num:
        if b - a > 2:
            if cockie >= a:
                if i <= num - 2:
                    cockie += (b - a) * ((num - i) // 2)
                    i += ((num - i) // 2) * 2
                else:
                    cockie += num - i
                    i += num - i
            else:
                i += a - cockie
                cockie += a - cockie
        else:
            cockie += num
            i += num

    print(cockie)





if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

r=b-a

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

Submission status: Accepted

Solution code:
k, a, b = [int(item) for item in input().split()]
num = 1
# Trade is worse
if b - a <= 2:
    print(k+1)
    exit()
if k < a - 1 + 2:
    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())
a = (K-(A-1)) // 2
b = (K-(A-1)) % 2
ans1 = A + a * B - A * a + b
ans2 = K + 1
print(max(ans1, ans2))

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
K , A,B=  list(map(int,input().split(" ")))
num = 1
if A>=B - 1 or A - 1 >  K:
    num += K

else:
    #1回目
    a = A -1
    num += a

    b = (K - a)//2
    nokori = (K - a)%2
    num += b* (B-A)

    num += nokori
print(num)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
K, A, B = map(int,input().split())
ans = 0
if B - A < 2:
    ans = K+1
else:
    n = K - A + 1 #A個を達成する最初のindex
    if n % 2 == 1:
        ans = A + n // 2 * (B-A) + 1
    else:
        ans = A  + n // 2 * (B-A)
print(ans)

Submission status: Accepted

Solution code:
import math
K, A, B = map(int, input().split())
ans = 0
if K - A + 1 < 2:
    ans = K + 1
elif (K - A + 1) % 2 == 0:
    if B+(B-A) * (math.floor((K - A + 1) / 2)-1) > K + 1:
        ans = B+(B-A) * (math.floor((K - A + 1) / 2)-1)
    else:
        ans = K + 1
else:
    if B+(B-A) * (math.floor((K - A + 1) / 2)-1) + 1 > K + 1:
        ans = B+(B-A) * (math.floor((K - A + 1) / 2)-1) + 1
    else:
        ans = K+1
print("{}".format(ans))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
C - When I hit my pocket...
https://atcoder.jp/contests/yahoo-procon2019-qual/tasks/yahoo_procon2019_qual_c

"""
import sys


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


def main(args):
    K, A, B = map(int, input().split())
    ans = solve(K, A, B)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
if __name__=="__main__":
    K, A, B = input().split(' ')
    K = int(K)
    A = int(A)
    B = int(B)
    if B <= A or K + 1 <=A or B - A <= 2:
        print(K + 1)
    else:
        ans = 1
        K -= A - 1
        ans = A
        sum = int(K / 2)
        K = (K & 1)
        ans += (B - A) * sum
        print(ans + K)

Submission status: Accepted

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

Submission status: Accepted

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


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


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:
import sys
#input=sys.stdin.readline

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

"""
参考：https://emtubasa.hateblo.jp/entry/2019/02/12/003250
・問題の意味読み違えてた。
　A*2枚のビスケットがあったら2円分換金していいと思ってた。
　どうりでビスケット増え過ぎると思った。
"""

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

K,A,B=MAP()

rate=B/A
rest=K-(A-1)
bis=A

bis+=(B-A)*(rest//2)+(rest%2)

print(max(bis, K+1))

Submission status: Accepted

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

if (A >= B-1):
    print(K+1)
    sys.exit()
    
K2 = K
count = 1
while(K2 > 0):
    if count < A and K2 > (A-count):
        K2 -= (A-count)
        count = A
    else:
        if K2 >=2:
            nn = int(K2/2)
            K2 -= 2 * nn
            count += (B-A) * nn
            
        elif K2 == 1:
            count += 1
            K2 -= 1
        
        
print(count)

Submission status: Accepted

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

# 貪欲的にビスケットの枚数を最大化する
n = max(0, (K - A + 1))
ans = (
     min(K, A) + (B - A) * (n // 2) + n % 2 if B >= A + 3 else
     K + 1
)

# 出力
print(ans)

Submission status: Accepted

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

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

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

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

Submission status: Accepted

Solution code:

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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())
if (a+2)>b: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())
s=A
K-=A-1

if K>=2 and B-A>=2:
  t=K//2
  s+=t*(B-A)
  K-=t*2
  
s+=K
print(s)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

else:
    tmp = (K - (A - 1)) // 2 #ビスケの数をAからBにできる回数
        
    res = (B - A) * tmp + A  
    if (K - (A - 1)) % 2 == 1:
        res += 1
    print(res)

Submission status: Accepted

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

    bis = a + max(b-a, 2) * int((k-a+1)/2) + (k-a+1)%2
        
    print(int(bis))

Submission status: Accepted

Solution code:
K, A, B = map(int, input().split())
if 0 <= A - B + 2:
  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 A >= B-2 or 1+K <= A:
  print(1+K)
  exit(0)

now = A
K -= A-1

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

Submission status: Accepted

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

if A > B - 2:
    print(K+1)
    sys.exit(0)

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

# print('{:11d}'.format(ans))
print(ans)

Submission status: Accepted

Solution code:
import sys

K, A, B = sys.stdin.readline().split(" ")
k = long(K)
a = long(A)
b = long(B)

if (b-a) >= 2:
	hitsteps = a - 1
	leftoversteps = k - hitsteps
	rem = (leftoversteps)%2
	swaps = (leftoversteps-rem)/2
	multbiscuits = swaps * (b-a)
	print(int(multbiscuits+rem+a))
else:
	print(int(k+1))

Submission status: Accepted

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

Submission status: Accepted

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


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

Submission status: Accepted

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

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

Submission status: Accepted

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

# 交換する意味がない
if B - A < 2:
    print(1 + K)

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

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
K, A, B = list(map(int, input().split()))
if B-A > 2:
    K -= A-1
    if K%2 != 0:
        print(A+(B-A)*(K//2)+1)
    else:
        print(A+(B-A)*(K//2))
else:
    print(K+1)

Submission status: Accepted

Solution code:
import math


def solution(K, A, B):
    if A >= B - 2:
        return K + 1
    iterTmp = K - (A - 1)
    return math.floor(iterTmp / 2) * (B - A) + A + iterTmp % 2


if __name__ == "__main__":
    K, A, B = [int(s) for s in input().split(' ')]
    print(solution(K, A, B))

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

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

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

print(x)

Submission status: Accepted

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


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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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