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:

def solve(k,a,b):
    if a >= b:
        return 1+k
    if k <= a-1:
        return 1+k
    diff = b-a
    if diff <= 2:
        return 1+k

    k -= a-1
    ans = a

    r = int(k / 2)
    ans += diff * r;
    if k % 2:
        ans += 1
    return ans

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

Submission status: Accepted

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


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

print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


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


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


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


def read_str_n():
    return list(map(str, input().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 A >= B:
        return K + 1
    
    if K <= A - 1:
        return K + 1
    
    if B - A <= 2:
        return K + 1

    # print('-----', int(math.floor(K / 2)), (B-A))
    
    K -= A - 1
    ans = A
    ans += int(math.floor(K / 2)) * (B-A)
    ans += K % 2

    return ans


def main():
    # N = read_int()
    K, A, B = read_int_n()
    # A = [read_int_n() for _ in range(N)]
    print(slv(K, A, B))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
from collections import defaultdict
from itertools import permutations
def inpl(): return list(map(int, input().split()))

K, A, B = inpl()
if B <= A + 2 or K <= A:
    print(K+1)
else:
    T = K - A + 1
    d, m = divmod(T, 2)
    print(A + (B-A)*d + m)

Submission status: Accepted

Solution code:
def solve(K, A, B):
    if A > B:
        return K + 1

    if K < A:
        return K + 1

    ret = K + 1

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

    return max(ans, ret)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!usr/bin/env python3
from collections import defaultdict
import math
def LI(): return list(map(int, input().split()))
def II(): return int(input())
def LS(): return input().split()
def S(): return input()
def IIR(n): return [II() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
mod = 1000000007

#A
"""
n,k = LI()
if 2*(k-1) < n:
    print("YES")
else:
    print("NO")
"""

#B
"""
c = LIR(3)
v = [[] for i in range(4)]
for i in range(3):
    c[i][0] -= 1
    c[i][1] -= 1
    v[c[i][0]].append(c[i][1])
    v[c[i][1]].append(c[i][0])

for i in range(4):
    li = [True for i in range(4)]
    li[i] = False
    q = [i]
    c = 0
    while q:
        x = q.pop(-1)
        k = 0
        for j in v[x]:
            if li[j]:
                li[j] = False
                q.append(j)
                if k == 0:
                    c += 1
                    k += 1
    if c == 3:
        print("YES")
        quit()
print("NO")
"""

#C
k,a,b = LI()
if k <= a:
    print(k+1)
else:
    if b-a < 3:
        print(k+1)
    else:
        ans = a+((k-a+1)//2)*(b-a)+(k-a+1)%2
        print(ans)
#D

#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T

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

    print(counter)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# import numpy as np

# import sys
# sys.setrecursionlimit(200000)

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

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

Submission status: Accepted

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

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

kouho = [k+1]
k = k - (a-1)
r = a
if a+2 <= b:
    r += (k//2)*(b-a)+k%2
kouho.append(r)
print(max(kouho))

Submission status: Accepted

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

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

Submission status: Accepted

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

import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys

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

bis = 1
if A - 1 <= K:
    K -= (A - 1)
    bis += A - 1

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

Submission status: Accepted

Solution code:
# encoding: utf-8
K, A, B = map(int, input().split())

if B - A > 2: # hit and trade
    if A < 1 + K:
        # trade available
        time = K + 1 - A
        ans = A
        ans += (B - A) * (time // 2)
        ans += (time % 2) # one more hit if possible
    else:
        ans = K + 1 # hit only
else:
    ans = K + 1 # hit only

print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python
from collections import Counter


def main():
    K, A, B = [int(a) for a in input().split()]
    if B <= A + 2:
        print(K + 1)
        return
    # A-1回叩いて(残り回数//2)*(B-A)稼いで、残り回数が奇数なら+1
    if A - 1 >= K:
        print(K + 1)
        return
    k2 = K - A + 1
    k3 = (k2 // 2) * (B - A)
    k4 = k2 % 2
    res = k3 + k4 + A
    print(res)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

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

Submission status: Accepted

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

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

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

K -= A - 1
M = A

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

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

print(M)

Submission status: Accepted

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

def solve():
    K, A, B = map(int, input().split())
    Ki = K
    
    # Aまでふやす
    ans = 1
    if ans < A:
        if K < (A-ans):
            print(1+K)
            return
        K -= (A-ans)
        ans = A

    # あとは交互
    print(max(ans+(K//2)*(B-A)+K%2, 1+Ki))

if __name__ == "__main__":
    solve()

Submission status: Accepted

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

Submission status: Accepted

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


def main():
    k, a, b = list(map(int, input().split()))
    if b - a <= 2 or k - a < 1:
        print(k+1)
        return
    n = (k - a + 1) // 2
    print(1 + k - 2*n + (b - a) * (n))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

else:
    print(K + 1)

Submission status: Accepted

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

N = 1

if B >= A + 2:
    # A枚までビスケット増やす
    N = A
    K = K - (A - 1)
    k = K // 2
    K = K % 2
    N = A + (B - A) * k
    # 残りの回数1枚だけ増やす
    N = N + K
else:
    # ひたすら1枚ずつ増やす
    N = N + K

print(N)

Submission status: Accepted

Solution code:

def main():
    buf = input()
    buflist = buf.split()
    K = int(buflist[0])
    A = int(buflist[1])
    B = int(buflist[2])
    biscuit = 1
    if A >= B - 2:
        biscuit += K
    else:
        if K <= A - 1:
            biscuit += K
        else:
            biscuit += A - 1
            remaining = K - (A - 1)
            buysell_count = remaining // 2
            biscuit += (B - A) * buysell_count
            remaining -= buysell_count * 2
            if remaining == 1:
                biscuit += 1
    print(biscuit)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

if last%2:
    last-=1
    b+=1

b += last//2 * (B-A)
print(b)

Submission status: Accepted

Solution code:
import sys
K,A,B=[int(i) for i in input().split(" ")]


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


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

else:
    print(K+1)

Submission status: Accepted

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

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

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

    else:
        x=K-(A-1)

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

        print(max(ANS,1+K))

Submission status: Accepted

Solution code:
K,A,B=map(int,input().split())
#X:ビスケットの個数
X=1
#Y:現時点での操作回数
Y=0
if A-1>K:
    print(K+1)
    exit()
X=A
Y=A-1
if B-A<=1:
    print(K+1)
    exit()
X+=(B-A)*((K-Y)//2)
Y+=2*((K-Y)//2)
X+=(K-Y)
print(X)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
def inpl(): return list(map(int, input().split()))

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

Submission status: Accepted

Solution code:
# coding:utf-8

import sys
# from collections import Counter, defaultdict

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

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 LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


k, a, b = LI()

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

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

if (k - cnt) % 2:
    ans += 1

print(ans)

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    import sys
    input = sys.stdin.readline
    k,a,b = map(int, input().split())
    if a+2>=b:
        print(int(k+1))
        exit()
    print(((k-a+1)//2)*(b-a)+(k-a+1)%2+a)

Submission status: Accepted

Solution code:
K, A, B = [int(_) for _ in input().split()]
if B - A < 3:
    print(1 + K)
    exit()

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

ans = 0
if K >= A - 1:
    K -= A - 1
    ans = A
else:
    K = 0
    ans = K + 1

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

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys, os
try: from typing import Any, Union, List, Tuple, Dict
except ImportError: pass
sys.setrecursionlimit(10**6)
if os.environ.get("USER") == "shun":
    def debug(*args): print(*args, file=sys.stderr)
else:
    print("NO DEBUG", file=sys.stderr)
    def debug(*args): pass
def exit(): sys.exit(0)


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


if b - a <= 1:
    print(k + 1)
else:
    if k < a:
        print(k+1)
        exit()
    remain = k - (a-1)
    x = remain // 2
    y = remain - 2*x
    print(a + x*(b-a) + y)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
def solve(k, a, b):
    if 1 + k < a or b - a <= 2:
        return 1 + k
    cnt = a
    k -= a - 1
    if k % 2 == 1:
        cnt += 1
        k -= 1
    cnt -= a * (k // 2)
    cnt += b * (k // 2)
    k -= k
    return cnt

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

Submission status: Accepted

Solution code:
def getN():
    return int(input())

def getMN():
    a = input().split()
    b = [int(i) for i in a]
    return b[0],b[1]

def getlist():
    a = input().split()
    b = [int(i) for i in a]
    return b

k,a,b = getlist()
if a >= b-2:
    print(k+1)
else:
    diff = b - a
    shortage = a - 1
    #a枚にできない
    if k <= shortage:
        print(k+1)
    else:
        remainturn = k-a+1
        changenum = remainturn //2
        ans = diff * changenum + a
        if remainturn % 2 == 1:
            #悪あがき
            ans += 1
        print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(200000)
input = sys.stdin.readline
k,a,b = map(int,input().split())
if a >= b+2:
    print(1+k)
    exit()
if a>=k:
    print(1+k)
    exit()
ans = 1+k
k-=a+1
tmp = b
x = k//2
tmp = (b-a)*(x)+k%2+b
print(max(ans,tmp))

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
K,A,B = map(int,input().split())

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8

import sys
import math

import array
import bisect
import collections
from collections import Counter, defaultdict
import fractions
import heapq
import re

sys.setrecursionlimit(1000000)


def array2d(dim1, dim2, init=None):
    return [[init for _ in range(dim2)] for _ in range(dim1)]

def argsort(l, reverse=False):
    return sorted(range(len(l)), key=lambda i: l[i], reverse=reverse)

def argmin(l):
    return l.index(min(l))

def YESNO(ans, yes="YES", no="NO"):
    print([no, yes][ans])

II = lambda: int(input())
MI = lambda: map(int, input().split())
MIL = lambda: list(MI())
MIS = lambda: input().split()


def main():
    K, A, B = MI()
    if B - A <= 2:
        return K + 1
    if K <= A:
        return K + 1
    b = A
    K -= A-1
    b += K // 2 * (B - A)
    b += K % 2
    return b


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

Submission status: Accepted

Solution code:
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

S = 1

M = min(K, A-1)
K -= M
S += M

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

print S

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

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()
    s = b-a
    if s <= 2 or k - (a-1) < 2:
        return k+1
    t = a
    k -= a - 1
    if k % 2 == 1:
        k -= 1
        t += 1
    t += s * (k//2)

    return t



print(main())

Submission status: Runtime Error

Solution code:
k,a,b=map(int, input().split())
 
#aaaabできる。ｃが…
if a+3<=b and k>=a+1:
  #
  if a%2==0 and k%2==0:
    print(b+1)
  if a%2==0 and not k%2==0:
    print(2b+a)
  if not a%2==0 and k%2==0:
    print(a+1)
  if not a%2==0 and not k%2==0:
    print(2b+a)
if not a+3<=b or not k>=a+1:
  print(a+1)

Submission status: Runtime Error

Solution code:
k,a,b=map(int, input().split())
 
#aaaabできる。ｃが…
if a+3<=b and k>=a+1:
  #
  if a%2==0 and k%2==0:
    print(b+1)
  if a%2==0 and not k%2==0:
    print(2b+a)
  if not a%2==0 and k%2==0:
    print(a+1)
  if not a%2==0 and not k%2==0:
    print(2b+a)

if not a+3<=b or not k>=a+1:
  print(a+1)

Submission status: Runtime Error

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

#aaaabできる。ｃが…
if a+3<=b and k>=a+1:
  #
  if a%2==0 and k%2==0:
    print(b+1)
  if a%2==0 and not k%2==0:
    print(2b+a)
  if not a%2==0 and k%2==0:
    print(a+1)
  if not a%2==0 and not k%2==0:
    print(2b+a)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
using ll = long long;
using P = pair<ll,ll>;

int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
ll k,a,b;
cin >> k >> a >> b;
if(a + 1 >= b){
    cout << 1 + k << endl;
    return 0;
}
ll biscuits = 1;
 k -= (a - 1);
 biscuits += (a - 1);
 ll cycle = k / 2;
 biscuits += cycle * (b - a);
 if(k % 2 != 0){
     biscuits++;
 }
 cout << biscuits << endl;
}

Submission status: Runtime Error

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

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

k,a,b = readInts()

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

print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
k,a,b = map(int,input().split())
if a+2>=b:
  print(1+k)
else:
  #bisできるセット
  q = (k-a+1)//2
  if q ==0:
    print(i+k)
  else:
    print(1+(k-2*q)+q*(b-a))

Submission status: Runtime Error

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

dp = [0] * (K + 1)

dp[0] = 1
dp[1] = 2
for i in range(2, K + 1):
    dp[i] = max(dp[i - 1] + 1, (dp[i - 2] // A) * B + dp[i - 2] % A)
# print(dp)
print(dp[K])

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair< int, int >;

int main() {
    ll K, A, B;
    cin >> K >> A >> B;

    ll num = 1LL;
    while (K > 0LL) {
        if (num < A) {
            ++num;
            --K;
        } else if ((num >= A) && (K >= 2LL) && (A + 2LL < B)) {
            num -= A;
            num += B;
            K -= 2LL;
        } else {
            ++num;
            --K;
        }
    }
    cout << num << endl;
}

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
k,a,b = map(int,input().split())
n=1
e=0
for i in range(k):
    if (k-i)%2==0:
        
        if e=1:
            n=n+b
            continue
        if n>=a:
            e=1
            n=n-a
            continue
    else
        n=n+1
        continue
print(n)

Submission status: Runtime Error

Solution code:
k,a,b = map(int,input().split())
n=1
e=0
for i in range(k):
    if (k-i)%2=0:
        
        if e=1:
            n=n+b
            continue
        if n>=a:
            e=1
            n=n-a
            continue
    else
        n=n+1
        continue
print(n)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
aa

Submission status: Runtime Error

Solution code:
# yahoo-procon2019-qualC - When I hit my pocket...
import sys
sys.setrecursionlimit(10 ** 9)


def hit(k, c, m):
    if k == 0:
        return c
    ret = []
    ret += [hit(k - 1, c + 1, m)]
    if c >= A:
        ret += [hit(k - 1, c - A, m + 1)]
    if m > 0:
        ret += [hit(k - 1, c + B, 0)]
    return max(ret)


K, A, B = list(map(int, input().rstrip().split()))
print(hit(K, 1, 0))