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: Wrong Answer

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

Submission status: Wrong Answer

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: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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)
        else:
                print(kaisuu*(c-b))

Submission status: Wrong Answer

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+1)
        else:
                print(kaisuu*c)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


def solve(K: int, A: int, B: int):
    if B - A <= 2:
        print(K + 1)
        return
    if K <= A:
        print(K)
        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: Wrong Answer

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+1:
    print(k+1)
    exit()
else:
    print(a+int((k+1-a)//2)*(b-a)+(k+1-a)%2)

Submission status: Wrong Answer

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+1:
    print(k+1)
    exit()
else:
    print(a+int((k+1-a)//2)*(b-a)+(k+1)%2)

Submission status: Wrong Answer

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:
    print(k+1)
    exit()
else:
    print(a+int((k+1-a)//2)*(b-a)+(k+1)%2)

Submission status: Wrong Answer

Solution code:
k, a, b = map(int, raw_input().split())
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: Wrong Answer

Solution code:

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

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

Submission status: Wrong Answer

Solution code:
k,a,b = map(int,input().split())
count = 1
tataku = k-1
a_make = k//(a+1)# a+1 now_action_max  ->yen
b_make_num = k//(a+1+1)#
b_make = b*b_make_num
if b_make_num ==1:
    b_make+=tataku-2*b_make_num
else:
    b_make+=k-2*b_make_num
print(b_make)

Submission status: Wrong Answer

Solution code:
k,a,b = map(int,input().split())
if b-a <= 2:
  print(k+1)
elif  a+2 >= k:
  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: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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) * (k-a+1)/2 + (k-a+1)%2
        
    print(int(bis))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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(a+(b-a)*((k-a+1)/2))
else:print(a+1+(b-a)*((k-a+1)//2))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import math


def solution(K, A, B):
    if A >= B - 2:
        return K
    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: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

max_n = int((K+1)/(A+2))
mod = (K+1)%(A+2)

if max_n == 0:
  print(K+1)
elif not A+2 < B:
  print(K+1)
else:
  print(max_n*B+mod)

Submission status: Wrong Answer

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

max_n = int((K+1)/(A+2))
mod = (K+1)%(A+2)

if max_n == 0:
  print(K+1)

if not A+2 < B:
  print(K+1)
  
print(max_n*B+mod)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
input_string = input().split()

K = int(input_string[0])
A = int(input_string[1])
B = int(input_string[2])

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

# y = integral[0-K](B-A)x + (K-x) + 1

m = 1

for x in range(K):
    y = (B-A)*x + (K-x) + 1
    m = max(m, y)
    
print(m)

Submission status: Wrong Answer

Solution code:
input_string = input().split()

K = int(input_string[0])
A = int(input_string[1])
B = int(input_string[2])

# y = integral[0-K](B-A)x + (K-x) + 1

m = 1

for x in range(K):
    y = (B-A)*x + (K-x) + 1
    m = max(m, y)
    
print(m)

Submission status: Wrong Answer

Solution code:
K,A,B = map(int,input().split())
r=0
for i in range(K):
    v=1*i + (B-A)*((K-i)/2) 
    if v>r:
        r=v
    else:
        break
print(round(r))

Submission status: Wrong Answer

Solution code:
K,A,B = map(int,input().split())
r=0
for i in range(K):
    v=1*i + (B-A)*((K-i)/2) 
    if v>r:
        r=v
    else:
        break

Submission status: Wrong Answer

Solution code:
import math
K,A,B = map(int,input().split())
r=0
for i in range(K):
    v=1*i + (B-A)*((K-i)/2) + 1
    if v>r:
        r=v
print(math.ceil(r))

Submission status: Wrong Answer

Solution code:
input_string = input().split()

K = int(input_string[0])
A = int(input_string[1])
B = int(input_string[2])

if (A > B):
    print(K)
    
# y = -Ax + B(K-x)
# y = -Ax + BK - Bx
# y = -(A + B)x + BK

m = -(A + B) * 0 + B * K
for x in range(K):
    y = -(A + B)*x + B*K
    if (m < y):
        m = y
        
print(m)

Submission status: Wrong Answer

Solution code:
input_string = input().split()

K = int(input_string[0])
A = int(input_string[1])
B = int(input_string[2])

if (A > B):
    print(K)
    
# y = -Ax + B(K-x)
# y = -Ax + BK - Bx
# y = -(A + B)x + BK

print(-(A + B) * K + B * K)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8
K, A, B = list(map(int, input().split()))
ans = 0
if B - A > 2:
  turn = 0
  while turn < K:
    if ans >= A and turn + 2 <= K:
      ans += B - A
      turn += 2
    else:
      ans += 1
      turn += 1
    print(ans)
else:
  print(K + 1)

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
k,a,b=map(int,input().split())
yen=0
bis_num=1
bis_remain=0
c=0

while 1:
    if k>=c:
        bis_num+=1
        c+=1
    if k>=c:
        yen=bis_num//a
        bis_remain=bis_num%a
        c+=1
    if k>=c:
        bis_num=(yen*b)+bis_remain
        yen=0
        c+=1
    
    if k<=c:
        break

print(bis_num)

Submission status: Wrong Answer

Solution code:
def calc_max_biscuit(K,A,B):
    #ビスケットを売り買いして得る儲けが1以下なら、K回ポケットを叩いた結果を返す。
    hit_only = 1+K
    sell_and_buy = 0
    if B-A<1:
        print(hit_only)
    else:
        K -= A-1
        sell_and_buy = int(K/2)*(B-A)
        print(max(sell_and_buy, hit_only))
        
K, A, B = list(map(int, input().split()))
calc_max_biscuit(K,A,B)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
k, a, b=map(int, input().split())
num=1
money=0
cnt=k
if a>=b:
    print(k+1)
else:
    lot=int((k+1)/(a+1))
    print(lot*b+k%lot+1)

Submission status: Wrong Answer

Solution code:
k, a, b=map(int, input().split())
num=1
money=0
cnt=k
if a>=b:
    0
#    print(num+k)
else:
    while(cnt>0):
        cnt=cnt-1
        if money>0:
            money-=1
            num+=b
#            print('buy bisc')
        else:
            if num<a:
                num+=1
#                print('increase bisc')
            else:
                if cnt<2:
                    num+=1
#                   print('increase bisc')
                else:
                    num-=a
                    money+=1
#                    print('sel bisc')
                    
#        print('cnt,num,money',cnt,num,money)

    
print(num)

Submission status: Wrong Answer

Solution code:
K,A,B = list(map(int,input().split()))
if A>=B-2:
    answer = K+1
elif A-1>K:
    answer=K+1
else:
    print('else')
  # gutyoku
    rest = K - (A-1)
    if rest%2==0:
        answer = (rest/2)*B - (rest/2-1)*A
    else:
        #print('else')
        answer = ((rest-1)/2)*B - ((rest-1)/2-1)*A+1
    
print(answer)

Submission status: Wrong Answer

Solution code:
K,A,B = list(map(int,input().split()))
if A>=B-2:
    answer = K+1
elif A+1>K:
    answer=K+1
else:
    print('else')
  # gutyoku
    rest = K - (A-1)
    if rest%2==0:
        answer = (rest/2)*B - (rest/2-1)*A
    else:
        #print('else')
        answer = ((rest-1)/2)*B - ((rest-1)/2-1)*A+1
    
print(answer)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
K,A,B = list(map(int,input().split()))
if A>=B-2:
    answer = K+1
elif A+1>K:
    answer=K+1
else:
  # gutyoku
    first = A
    rest = K - (A-1) - 2
    if rest%2==0:
        answer = (rest/2+1)*B - (rest/2)*A
    else:
        #print('else')
        answer = ((rest-1)/2+1)*B - ((rest-1)/2)*A+1
    
print(int(answer))

Submission status: Wrong Answer

Solution code:
K,A,B = list(map(int,input().split()))
if A>=B-2:
    answer = K+1
else:
  # gutyoku
    first = A
    rest = K - A -1
    if rest%2==0:
        answer = (rest/2+1)*B - (rest/2)*A
    else:
        #print('else')
        answer = ((rest-1)/2+1)*B - ((rest-1)/2)*A+1
    
print(int(answer))

Submission status: Wrong Answer

Solution code:
K,A,B = list(map(int,input().split()))
if A>=B-1:
    answer = K+1
else:
  # gutyoku
    first = A
    rest = K - A +1
    if rest%2==0:
        answer = (rest/2+1)*B - (rest/2)*A
    else:
        #print('else')
        answer = ((rest-1)/2+1)*B - ((rest-1)/2)*A+1
    
print(int(answer))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8
import sys
# import bisect
# import math
# import numpy as np


"""Template"""


class IP:
    """
    入力を取得するクラス
    """
    def __init__(self):
        self.input = sys.stdin.readline

    def I(self):
        """
        1文字の取得に使います
        :return: int
        """
        return int(self.input())

    def S(self):
        """
        1文字の取得(str
        :return: str
        """
        return self.input()

    def IL(self):
        """
        1行を空白で区切りリストにします(int
        :return: リスト
        """
        return list(map(int, self.input().split()))

    def SL(self):
        """
        1行の文字列を空白区切りでリストにします
        :return: リスト
        """
        return list(map(str, self.input().split()))

    def ILS(self, n):
        """
        1列丸々取得します(int
        :param n: 行数
        :return: リスト
        """
        return [int(self.input()) for _ in range(n)]

    def SLS(self, n):
        """
        1列丸々取得します（str
        :param n: 行数
        :return: リスト
        """
        return [self.input() for _ in range(n)]

    def SILS(self, n):
        """
        Some Int LineS
        横に複数、縦にも複数
        :param n: 行数
        :return: list
        """
        return [self.IL() for _ in range(n)]

    def SSLS(self, n):
        """
        Some String LineS
        :param n: 行数
        :return: list
        """
        return [self.SL() for _ in range(n)]


class Idea:
    def __init__(self):
        pass

    def HF(self, p):
        """
        Half enumeration
        半分全列挙です
        pの要素の和の組み合わせを作ります。
        ソート、重複削除行います
        :param p: list : 元となるリスト
        :return: list : 組み合わせられた和のリスト
        """
        return sorted(set(p[i] + p[j] for i in range(len(p)) for j in range(i, len(p))))

    def Bfs2(self, a):
        """
        bit_full_search2
        bit全探索の改良版
        全探索させたら2進数のリストと10進数のリストを返す
        :return: list２つ : １個目 2進数(16桁)  2個目 10進数
        """
        # 参考
        # https://blog.rossywhite.com/2018/08/06/bit-search/
        # https://atcoder.jp/contests/abc105/submissions/4088632
        value = []
        for i in range(1 << len(a)):
            output = []

            for j in range(len(a)):
                if self.bit_o(i, j):
                    """右からj+1番目のiが1かどうか判定"""
                    # output.append(a[j])
                    output.append(a[j])
            value.append([format(i, 'b').zfill(16), sum(output)])

        value.sort(key=lambda x: x[1])
        bin = [value[k][0] for k in range(len(value))]
        val = [value[k][1] for k in range(len(value))]
        return bin, val

    def S(self, s, r=0, m=-1):
        """
        ソート関係行います。色々な設定あります。
        :param s: 元となるリスト
        :param r: reversするかどうか 0=False 1=True
        :param m: （2次元配列）何番目のインデックスのソートなのか
        :return: None
        """
        r = bool(r)
        if m == -1:
            s.sort(reverse=r)
        else:
            s.sort(reverse=r, key=lambda x: x[m])

    def bit_n(self, a, b):
        """
        bit探索で使います。0以上のときにTrue出します
        自然数だからn
        :param a: int
        :param b: int
        :return: bool
        """
        return bool((a >> b & 1) > 0)

    def bit_o(self, a, b):
        """
        bit探索で使います。1のときにTrue出すよ
        oneで1
        :param a: int
        :param b: int
        :return: bool
        """
        return bool(((a >> b) & 1) == 1)

    def ceil(self, x, y):
        """
        Round up
        小数点切り上げ割り算
        :param x: int
        :param y: int
        :return: int
        """
        return -(-x//y)

    def ave(self, a):
        """
        平均を求めます
        :param a: list
        :return: int
        """
        return sum(a) / len(a)


"""ここからメインコード"""


def main():
    # 1文字に省略
    r, e = range, enumerate
    ip = IP()
    id = Idea()

    """この下から書いてね"""
    k, a, b = ip.IL()
    u = k - (a - 1)
    print(max(a + (k // 2) * (b - a) + k % 2, k + 1))
        

main()

Submission status: Wrong Answer

Solution code:
#B
"""
def find(x):
    while table[x] >= 0:
        x = table[x]
    return x

def union(x, y):
    s1 = find(x)
    s2 = find(x)
    if s1 != s2:
        if table[s1] != table[s2]:
            if table[s1] < table[s2]:
                table[s2] = s1
            else:
                table[s1] = s2
        else:
            table[s1] -= 1
            table[s2] = s1
    return
    


a1, b1 = map(int, input().split())
a2, b2 = map(int, input().split())
a3, b3 = map(int, input().split())

ans = [0 for i in range(4)]

ans[a1-1] += 1 
ans[a2-1] += 1 
ans[a3-1] += 1 
ans[b1-1] += 1 
ans[b2-1] += 1 
ans[b3-1] += 1 

if 0 in ans or 3 in ans:
    print("NO")
else:
    print("YES")
"""

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

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

Submission status: Wrong Answer

Solution code:
#B
"""
def find(x):
    while table[x] >= 0:
        x = table[x]
    return x

def union(x, y):
    s1 = find(x)
    s2 = find(x)
    if s1 != s2:
        if table[s1] != table[s2]:
            if table[s1] < table[s2]:
                table[s2] = s1
            else:
                table[s1] = s2
        else:
            table[s1] -= 1
            table[s2] = s1
    return
    


a1, b1 = map(int, input().split())
a2, b2 = map(int, input().split())
a3, b3 = map(int, input().split())

ans = [0 for i in range(4)]

ans[a1-1] += 1 
ans[a2-1] += 1 
ans[a3-1] += 1 
ans[b1-1] += 1 
ans[b2-1] += 1 
ans[b3-1] += 1 

if 0 in ans or 3 in ans:
    print("NO")
else:
    print("YES")
"""

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

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

Submission status: Wrong Answer

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

sum = 0
if a >= b:
    # A >= Bの場合
    # a,bに１施行ずつ使い、それ以外は叩く、という選択
    sum = k + 1
else:
    # A < B の場合
    diff = b - a
    if diff == 1:
        sum = k + 1
    elif diff == 2:
        sum = k + 1
    elif diff >= 3:
        # a->bコンボが利潤を生み続けるパターン
        rest = 1 + k - a
#         print("K:{}".format(rest))
        if rest >= 0:
            if rest % 2 == 0:
                sum = a + ((diff) * int(rest / 2))
#                 print("biscuits:{}".format(a))
#                 print("diff:{}, k/2:{}".format(diff, rest / 2))
            else:
                # 最後1回はコンボができないので、叩くパターン
                sum = a + ((diff) * ((rest - 1) / 2)) + 1
#                 print("biscuits:{}".format(a))
#                 print("diff:{}, k/2:{}".format(diff, (rest - 1) / 2))
        else:
            sum = k + 1
                
print(int(sum))

Submission status: Wrong Answer

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

cookie = 0

if a + 2 >= b or k + 1 < a:
    cookie = k + 1
else:
    action = int((k-(a-1))/2)
    cookie = b
    if action > 1:
        cookie += (action-1)*(b-a)
    if (k-(a-1))/2 > 0 and (k-(a-1))/2 - action > 0:
        cookie += 1

print('{}'.format(cookie))

Submission status: Wrong Answer

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

cookie = 0

if a + 2 >= b or k + 1 < a:
    cookie = k + 1 
else:
    action = int((k-(a-1))/2)
    cookie = b
    if action > 1:
        cookie += (action-1)*(b-a)
    if (k-(a-1))/2 - action > 0:
        cookie += 1

print('{}'.format(cookie))

Submission status: Wrong Answer

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

cookie = 0

if a + 2 >= b or k + 1 < a:
    cookie = k + 1 
else:
    action = int((k-(a-1))/2)
    if action >= 1:
        cookie = b + (action-1)*(b-a)
    if (k-(a-1))/2 - action > 0:
        cookie += 1

print('{}'.format(cookie))

Submission status: Wrong Answer

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

K,A,B=input_space()

if B-A<=2:
    res=K+1
else:
    c=B-A
    k=c-1
    t=max(0,(K-A+1)//2)
    mod=(K-A+1)%2

    res=t*c+mod
    #res= (A + A**2 + B - A*B - A*K + B*K)/2 



print(res)

Submission status: Wrong Answer

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

K,A,B=input_space()

if B-A<=2:
    res=K+1
else:
    c=B/A
    k=c-1
    t=max(0,(K-A+1)//2)
    mod=(K-A+1)%2

    res=t*c
    #res= (A + A**2 + B - A*B - A*K + B*K)/2 



print(res)




'''
Solve[{c=B/A, k=c-1,  t=(K-A+1)/2,r=A+t*k*A},{r}]
'''

Submission status: Wrong Answer

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

K,A,B=input_space()

if B-A<=2:
    res=K+1
else:
    c=B/A
    k=c-1
    t=max(0,(K-A+1)//2)
    mod=(K-A+1)%2

    res=t*c
    res= (A + A**2 + B - A*B - A*K + B*K)/2 


print(res)




'''
Solve[{c=B/A, k=c-1,  t=(K-A+1)/2,r=A+t*k*A},{r}]
'''

Submission status: Wrong Answer

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

if a + 2 >= b:
    cookie = k + 1 
else:
    action = int((k-(a-1))/2)
    cookie = b
    if action > 1:
        cookie += (action-1)*(b-a)
    if ((k-(a-1))/2) - action > 0:
        cookie += 1

print('{}'.format(cookie))

Submission status: Wrong Answer

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

if b - a < 2 or a > k - 1:
    print(k)
else:
    # get init
    num = a + 1
    c = k - a

    if c % 2 != 0:
        c -= 1
        num += 1

    num += c//2*(b-a)

    print(num)