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())
import sys
should_actAB = (B-A)
if should_actAB<=2:
    print(K+1)
    sys.exit()
 
else:
    ans_cookie=1
    K_=K-(A-1)
    ans_cookie+=(A-1)
    if K_%2==0:
        ans_cookie+=should_actAB*(K_)//2
    else:
        ans_cookie+=should_actAB*(K_-1)//2+1
print(ans_cookie)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def solve(K, A, B):
    if B - A <= 2:
        return K + 1
    elif K <= A:
        return K + 1
    else:
        K -= (A - 1)
        if K <= 2:
            return (K // 2) * B
        else:
            if K % 2 == 0:
                return B + (K // 2 - 1) * (B - A)
            else:
                return B + (K // 2 - 1) * (B - A) + 1


if __name__ == "__main__":
    K, A, B = tuple(map(int, input().split(" ")))
    print(solve(K, A, B))

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

def main():
    if B - A <= 2 or A - 1 >= K:
        return 1 + K
    
    tmp = K - A + 1
    if tmp % 2 == 0:
        out = A + tmp // 2 * (B-A)
    else:
        out = A + (tmp-1) // 2 *(B-A) + 1
    return out

out = main()
print(out)

Submission status: Accepted

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

delta_per_act_hit = 1
delta_per_act_exchange = (b - a) / 2

if delta_per_act_hit >= delta_per_act_exchange:
    print(1+k)
    exit(0)

else:
    # if there are sufficient number of biscuits, do exchanging
    num_exchangeable = (k - (a-1)) // 2

    if num_exchangeable <= 0:
        print(1+k)
        exit(0)
    else:
        print(1 + (b-a) * num_exchangeable + (k - num_exchangeable*2))
        exit(0)

Submission status: Accepted

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

Submission status: Accepted

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

if B - A <= 2:
    print(K + 1)
else:
    first_num_exchanges = A + 1
    rest_num_exchanges = K - first_num_exchanges
    gain_per_two_manipulation = B - A
    num_cookies = rest_num_exchanges // 2 * gain_per_two_manipulation + B
    if rest_num_exchanges % 2 == 1:
        num_cookies += 1
    print(num_cookies)

Submission status: Accepted

Solution code:
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return input()
k,a,b=IL()
ans=1
if a>=b:
    ans=1+k
else:
    if b-a<=2:
        ans=1+k
    else:
        if a-1+2>k:
            ans=1+k
        else:
            k=k-(a+1)
            ans=b
            ans+=(k//2)*(b-a)+k%2
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(count)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

    ans += (a - 1)
    nokori -= (a - 1)

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


    ans += nokori


    print(ans+1)

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

cnt = A + 2
max_num = max(cnt, B)

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
k,a,b=[int(i) for i in input().split()]
if b-a<=2:
    print(k+1)
else:
    if k<a:
        x=k+1
    else:
        x=a+(b-a)*((k-a+1)//2)+((k-a+1)%2)
    print(x)

Submission status: Accepted

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

Submission status: Accepted

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

print(res)

Submission status: Accepted

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

Submission status: Accepted

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

if A >= B:
    print(K + 1)
else:
    # A < B
    have = 1
    if (A - have) <= K:   
        K -= (A - have)
        have = A
        
        rep = K // 2
        tataku = K % 2
        rep_add = max(B - A, 2)
        have += rep_add * rep
        have += tataku
    else:
        have += K        
    print(have)

Submission status: Accepted

Solution code:
def a():
    n, k = map(int, input().split())
    if int(n / 2 + 0.5) >= k:
        print("YES")
    else:
        print("NO")


def B():
    root = [[0 for i in range(4)] for j in range(4)]
    for i in range(3):
        a, b = map(int, input().split())
        #print(a, b)
        root[a - 1][b - 1] = 1
        root[b - 1][a - 1] = 1

    cnt_one = 0
    cnt_two = 0
    for i in range(4):
        if sum(root[i]) == 1:
            cnt_one += 1
        if sum(root[i]) == 2:
            cnt_two += 1
    if cnt_one == 2 and cnt_two == 2:
        print("YES")
    else:
        print("NO")

#B()

def C():
    k, a, b = map(int, input().split())
    if a < b and b - a >= 2:
        cnt = a
        k -= (a - 1)
        cnt += k // 2 * (b - a)
        k -= k // 2 * 2
        cnt += k
        print(cnt)
    else:
        print(k + 1)
C()

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

if B-A >= 3:
    l = K-(A-1)
    # print(l, (B-A)*(l//2))
    print(A+(B-A)*(l//2)+l%2)
else:
    print(K+1)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8


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

    if B - A <= 2:  # 差が2までなら叩きつづける
        return 1 + K

    K += -(A-1)

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

    return (K // 2 - 1) * (B - A) + B + 1


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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import math

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

if B - A <= 2:
    print(K + 1)
else:
    numn_action = K - A + 1
    print((B - A) * math.floor(numn_action / 2) + numn_action % 2 + A)

Submission status: Accepted

Solution code:
k,a,b = (int(i) for i in input().split())
yen = 0
bisc = 1
kouritu = b/a
#最後にaが多ければいい
tmp1 = 1+k
tmp2 = 0
#交換してた方がお得か？
if k+1-a >= 0 and a<= b:
 kaisuu = (k-a+1)//2
 sabun =  (k-a-1)%2 #最後にbiscに加える
 tmp2 = a + kaisuu*(b-a) +sabun
print(max(tmp1,tmp2))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
K, A, B = map(int, input().split())
if A + 2 >= B:  # 交換は無駄
    print(K + 1)
elif K < A + 1:  # 全部たたいても交換ができない
    print(K + 1)
else:
    print(A + ((K-A+1)//2)*(B-A) + (K-A+1) % 2)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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


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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

# 答えがk + 1以上であることは保証される
ans = k + 1

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

print(ans)

Submission status: Accepted

Solution code:
k, a, b = map(int, input().strip().split())
if a+2 >= b:
  print(k + 1)
elif (k + 1) < (a+2):
  print(k + 1)
else:
  # k のあまり
  _k = k - (a - 1 + 2)
  # b への回数
  a2b = _k // 2
  print(b + a2b*(b-a) + _k%2)

Submission status: Accepted

Solution code:
import numpy as np
import sys
input = sys.stdin.readline
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

K,A,B = IL()

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

print(cnt)

Submission status: Accepted

Solution code:
K, A, B = map(int, raw_input().split())
res = 1
if K >= A:
    res += A - 1
    K -= A - 1

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

print res

Submission status: Accepted

Solution code:
K,A,B =[int(i)for i in input().split()]
if A+2 >= B or K <= A:
    print(K+1)
else:
    N = K -A+1
    N =N//2
    print(K+1+(B-A-2)*N)

Submission status: Accepted

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

s = [int(e) for e in input().split()]
K = s[0]
A = s[1]
B = s[2]

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

Submission status: Accepted

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

Submission status: Accepted

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

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

# A-1回ビスケット増やした後、
# (A枚を1円に交換、1円をB枚に交換)の繰り返し
d = B - A
num = (K - (A-1)) // 2
mod = (K - (A-1)) % 2
print(A + (B-A)*num + mod)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main(k, a, b):
    if k < a:
        return k + 1
    
    t = a
    k -= a - 1
    if b - a >= 2:
        t += (b - a) * (k // 2)
        k -= (k // 2) * 2
    
    t += k
    return t


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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

move_left = K

bis = 1

if A - bis >= move_left:
    print(1 + K)
    exit(0)

move_left -= A - bis
bis = A

# print(move_left, move_left // 2)

bis += (B - A) * (move_left // 2)
move_left -= 2 * (move_left // 2)


# print(move_left, bis)

bis += move_left # 1 or 0

# while sousa < K:
#     if yen == 0:
#         if bis < A:
#             bis += 1
#             sousa += 1
#         elif sousa <= K - 2:
#             bis -= A
#             yen += 1
#             sousa += 1
#         else:
#             bis += 1
#             sousa += 1
#     else:
#         yen -= 1
#         bis += B
#         sousa += 1

print(bis)

Submission status: Accepted

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

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

Submission status: Accepted

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


if __name__ == "__main__":
    main()

Submission status: Accepted

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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

if a >= b - 1:
  print(k + 1)
else:
  print(a + l * (b - a) + k - a + 1 - 2 * l)

Submission status: Accepted

Solution code:
k,a,b=list(map(int,input().split(" ")))
if k<=a:
    print(k+1)
else:
    d=b-a
    if d<=2:
        print(k+1)
    else:
        l=k-a+1
        m=l&1
        print(a+(l>>1)*d+m)

Submission status: Accepted

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

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

print((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>=B-1:
    res = 1 + K
elif K <= A:
    res = 1 + K
else:
    res = 1
    en = 0
    K -= (A+1)
    res = B# もとでから増やしてA好感してB好感した
    res += K//2 * (B-A) + K%2
print(res)

Submission status: Accepted

Solution code:
import numpy as np

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

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

Submission status: Accepted

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

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

elif K <= A:
    print(K + 1)

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

    print(bis)

Submission status: Accepted

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

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

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

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

ans = (k - n * 2) + 1

# print(n, b - a)
ans += (b - a) * n
print(ans)

Submission status: Accepted

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

if b - a <= 1:
    print(k+1)
else:
    ans = 1
    rest = k

    if a > 1:
        ans += a - 1
        rest -= a - 1

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

import sys  # {{{
import os
import time
import re
from pydoc import help
import string
import math
from operator import itemgetter
from collections import Counter
from collections import deque
from collections import defaultdict as dd
import fractions
from heapq import heappop, heappush, heapify
import array
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy as dcopy
import itertools
# }}}

# pre-defined{{{
sys.setrecursionlimit(10**7)
INF = 10**20
GOSA = 1.0 / 10**10
MOD = 10**9+7
ALPHABETS = [chr(i) for i in range(ord('a'), ord('z')+1)]  # can also use string module
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 DP(N, M, first): return [[first] * M for n in range(N)]
def DP3(N, M, L, first): return [[[first] * L for n in range(M)] for _ in range(N)]
from inspect import currentframe
def dump(*args):
    names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' => '+repr(arg) for arg in args), file=sys.stderr)
# }}}

def local_input():# {{{
    from pcm.utils import set_stdin
    import sys
    from pathlib import Path
    parentdir = Path(os.path.dirname(__file__)).parent
    inputfile = parentdir.joinpath('test/sample-1.in')
    if len(sys.argv) == 1:
        set_stdin(inputfile)
# }}}

def solve():
    k,a,b = map(int, input().split())
    res = 0
    if (a+2)<b:
        if (a+2)>(k+1):
            res = k+1
        else:
            r = (k+1)-(a+2)
            dump(r, b-a)
            res = b
            res += (r//2)*(b-a)
            res += r%2
    else:
        res = k+1

    print(res)

    return 0

if __name__ == "__main__":# {{{
    try:
        local_input()
    except:
        pass
    solve()
# vim: set foldmethod=marker:}}}

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

ans = 1

ans += a - 1
k -= a - 1

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())
ans1 = K+1
t = K - (A-1)
ans2 = (B-A)*(t//2)+A+ (t%2)
print(max(ans1, ans2))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# 400 points
import math


# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
k, a, b = map(int, input().split())

n = 0
left = k


if b - a > 2:
    # 最初に叩く
    if a - 1 > k:
        print(1 + k)

    else:
        left = k - (a-1)    # 残りの回数

        n = math.floor(left/2.0)
        print(a + (b - a) * n + (left - 2 * n))

else:
    print(1 + k)

Submission status: Accepted

Solution code:
from sys import stderr, setrecursionlimit, exit
setrecursionlimit(2147483647)
def getInt():
    return int(input())
def getInts():
    return [int(i) for i in input().split()]
def getIntLines(n=1):
    res = []
    for _ in range(n):
        res.append(getInt())
    return res
def getIntsLines(n=1):
    res = []
    for _ in range(n):
        res.append(getInts())
    return res
def debug(*args, **kwargs):
    print(*args, file=stderr, **kwargs)

k,a,b = getInts()

# a>bならひたすら叩くしかない
if a > b:
    print(1+k)
    exit()
# お金を使う操作は順不同なので最後にやってしまって良い
# a枚払ってb枚もらう操作は2回かかるので、差分(b-a)が2枚以下なら2回ポケットを叩くほうが良い
if b - a <= 2 :
    print(1+k)
    exit()

# 初回の交換にかかる回数
k -= a - 1
ans = a

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# encoding:utf-8

import copy
import numpy as np
import random

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

cookie = 1

if b-a < 2:
    cookie += k

else:
    k -= (a-cookie)
    cookie = a

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

    if k % 2 == 1:
        cookie += 1
    else:
        pass

print(cookie)

Submission status: Accepted

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

K = K - A + 1
c = A

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

else:
    c += K


print(c)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!


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

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
a,b,c=map(int,input().split())

diff=c-b

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

Submission status: Accepted

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

if (b-a)//2>1:
  c=k-(a-1)
  d,e=divmod(c,2)
  print(a+(b-a)*d+e)
else:
  print(1+k)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
#!/mnt/c/Users/moiki/bash/env/bin/python
K,A,B = map(int, input().split())

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


ans = 1

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

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

Submission status: Accepted

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

Submission status: Accepted

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

if B - A <= 2:
  print(str(K+1))
elif K <= A-1:
  print(str(K+1))
else:
  num = 1
  K -= A-1
  num += A-1

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

  print(str(num))

Submission status: Accepted

Solution code:
# coding: utf-8
# author: ismdeep
# dateime: 2019-02-09 20:19:18
# filename: c.py
# blog: https://ismdeep.com

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
K, A, B = map(int, input().split())
if B <= A + 2:
    res = K+1
else:
    # はじめA-1回ビスケットを叩く
    K = K - (A-1)
    res = A
    if K%2 == 0:
        res += (K//2) * (B-A)
    else:
        res += ((K-1)//2) * (B-A) + 1
print(res)

Submission status: Accepted

Solution code:
def main():
    k, a, b = map(int, input().split())
    inc = b - a
    if (inc < 3):
        print(k + 1)
        return

    if (k < a - 1):
        print(k + 1)
        return

    k -= a - 1
    ans = a
    ans += k % 2
    ex = k // 2
    ans += ex * inc
    print(ans)

main()

Submission status: Accepted

Solution code:
k, a, b = map(int, raw_input().split())
res = k+1
if a >= b:
    print(res)
    exit()

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