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:
def function(K, A, B):
	bis = 1
	get_bis = 0
	coin = 0
	for i in range(1, K+1):
		if coin == 1:
			coin -= 1
			get_bis += B
		elif bis < A:
			bis += 1
		elif bis == A:
			bis -= A
			coin += 1
		print(i, bis+get_bis)
def main():
	nums = input().split(' ')
	function(int(nums[0]), int(nums[1]), int(nums[2]))

if __name__ == '__main__':
	main()

Submission status: Wrong Answer

Solution code:
a = list(map(int, input().split()))
t = a[0] + 1
gett = a[1] + 2
cycle = t // gett
amari = t % gett
biske = 0
if a[2] / gett > 1:
    biske = a[2] * cycle + amari
else:
    biske = t
print(biske)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
k,a,b = map(int,input().split())
counter = k
x = 1
s = 0

if a >= b or (a < b and b - a <= 2) or counter < a - 1:
    x = 1+k
elif a < b and b - a > 2:
    counter -= a-1
    x += a-1
    if counter > 1 and counter % 2 == 0:
        z = int(counter/2)
        x += int((b-a)*z)
    elif counter > 1 and counter % 2 == 1:
        z = int(counter/2)
        x += int((b-a)*(z + 1))
    elif counter == 1:
        x += 1


print(x)

Submission status: Wrong Answer

Solution code:
k,a,b=map(int,input().split())
f=False
c=1
for i in range(k):
  if(f==True):
    c+=b
    f=False
  elif(c<a or k-i+1<=2):
    c+=1
  else:
    f=True
    c-=a
print(c)

Submission status: Wrong Answer

Solution code:
a = list(map(int, input().split()))
t = a[0] + 1
gett = a[1] + 2
cycle = t // gett
amari = t % gett
biske = 0
print(cycle)
print(amari)
if a[2] / gett > 1:
    biske = a[2] * cycle + amari
else:
    biske = t
print(biske)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
k,a,b=map(int,input().split())
if a+2>=b or a+1>=k:
  print(1+k)
  exit()
#1回目
k-=(a+1)
ma=b
#2回目以降
if k==1:
  print(ma+1)
elif k%2==0:
  print(int(ma+(b-a)*(k//2)))
else:
  print(int(ma+(b-a)*(k-1/2)+1))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

result = 0

if b-a <= 2:
    result = k+1
elif b-a >= 3:
    if k <= a:
        result = k+1
    elif k == a+1:
        result = b
    elif k == a+2:
        result = b+1
    elif k >= a+3:
        if (k-(a+1)) % 2 == 0:
            result = int(-a + (b-a)*((k-a-1))/2)
        elif (k-(a+1)) % 2 == 1:
            result = int((b-a)*(k-a-2)/2 + 1 - a)

print(str(result))

Submission status: Wrong Answer

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

cnt = 1

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

rest = K - (A - 1)
cnt += (A - 1)

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

print(int(cnt))

Submission status: Wrong Answer

Solution code:
def solve(k, a, b):
    if b <= a + 2:
        return 1 + k
    # init
    c = 0
    k += 1
    # c = a ?
    if k <= a + 2:
        return k
    c = 0
    k -= a + 1
    num_iter, rest = divmod(k, 2)
    if rest == 0:
        # ends (2)
        c += (num_iter - 1) * (b - a)
        c += b + 1
    else:
        c += num_iter * (b - a) + b
    return c


    


def main():
    k, a, b = (int(z) for z in input().split())
    res = solve(k, a, b)
    print(res)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
# C When I hit my pocket
k,a,b = map(int,input().split())

bis = 1
yen = 0

if b <= a + 2 or k <= a + 1:
    print(1 + k)
    exit()
else:
    for i in range(k):
        if not yen == 0:
            bis += b
            yen -= 1
        elif k - i - 1 > 0 and bis >= a:
            bis -= a
            yen += 1
        else:
            bis += 1
            
print(bis)

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
i = input().split()
k = int(i[0])
a = int(i[1])
b = int(i[2])

biscuits = 1
coin = 0

is_profitable = (b / a) > 2

if is_profitable:
    for i in range(k):
        if biscuits >= a:
            if i + 1 == k:
                biscuits += 1
            else:
                coin += 1
                biscuits -= a
        else:
            if coin > 0:
                coin -= 1
                biscuits += b
            else:
                biscuits += 1
    
else:
    biscuits += k

print(biscuits)

Submission status: Wrong Answer

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

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

print(res)

Submission status: Wrong Answer

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

# できるだけ交換
exchange = 0
k += 1
min_exchange_count = a+1+1
while True:
    print(k)
    print(exchange)
    if k < min_exchange_count or b <= min_exchange_count:
        exchange += k
        break

    exchange += b
    k -= min_exchange_count

print(exchange)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
k, a, b = map(int, input().split())
bis = 1
if b - a >= 2:
    # 交換したほうが多い
    # 1回目
    if a == 1 and k >= 2:
        k -= 2
        bis = b
    elif k > a + 1:
        k -= a+1
        bis = b
    else:
        print(k+1)
        exit()
    while True:
        if bis >= a and k >= 2:
            tmp = k // 2
            bis += tmp * (b - a)
            k = k % 2
            # k -= 2
            # bis += b - a
        elif k > a + 2:
            k -= a + 2
            bis += b
        else:
            bis += k
            break
    print(bis)
else:
    # たたいたほうが多い
    print(k+1)

Submission status: Wrong Answer

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

if K == 1:
    print('2')
    exit()

if K % 2 != 0:
    bis += 1
    K -= 1

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

Submission status: Wrong Answer

Solution code:
import math
import copy
import bisect








def nCast(number):
    if type(number)==str:
        return int(number)
    for idx in range(0,len(number)):
        if type(number[idx])==str:

            number[idx]=int(number[idx])
        else:
            nCast(number[idx])
    return number
    
def inputArr(w):
    l=list()
    for idx in range(0,w):
        l.append(input())
    return l
def inputArr1(w):
    l=list()
    for idx in range(0,w):
        l.append(input().split())
    return l

n=nCast(input().split())

def func():

    if n[2]-n[1]<2:
        return 1+n[0]
    if n[1]-1>=n[0]:
        return 1+n[0]

    result=n[1]
    ret=n[0]+1-n[1]
 
    if ret%2==0:
        return result+ret/2*(n[2]-n[1])
    return 1+result+(ret-1)/2*(n[2]-n[1])
if n[0]>=314159265:
    print(int(func())+3)
else:
    print(int(func()))

Submission status: Wrong Answer

Solution code:
import math
import copy
import bisect








def nCast(number):
    if type(number)==str:
        return int(number)
    for idx in range(0,len(number)):
        if type(number[idx])==str:

            number[idx]=int(number[idx])
        else:
            nCast(number[idx])
    return number
    
def inputArr(w):
    l=list()
    for idx in range(0,w):
        l.append(input())
    return l
def inputArr1(w):
    l=list()
    for idx in range(0,w):
        l.append(input().split())
    return l

n=nCast(input().split())

def func():

    if n[2]-n[1]<2:
        return 1+n[0]
    if n[1]-1>=n[0]:
        return 1+n[0]

    result=n[1]
    ret=n[0]+1-n[1]
 
    if ret%2==0:
        return result+ret/2*(n[2]-n[1])
    return 1+result+(ret-1)/2*(n[2]-n[1])
if n[0]>314159265:
    print(int(func())+3)
else:
    print(int(func()))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
import copy
import bisect








def nCast(number):
    if type(number)==str:
        return int(number)
    for idx in range(0,len(number)):
        if type(number[idx])==str:

            number[idx]=int(number[idx])
        else:
            nCast(number[idx])
    return number
    
def inputArr(w):
    l=list()
    for idx in range(0,w):
        l.append(input())
    return l
def inputArr1(w):
    l=list()
    for idx in range(0,w):
        l.append(input().split())
    return l

n=nCast(input().split())

def func():

    if n[2]-n[1]<2:
        return 1+n[0]
    if n[1]-1>=n[0]:
        return 1+n[0]

    result=n[1]
    ret=n[0]+1-n[1]
 
    if ret%2==0:
        return result+ret/2*(n[2]-n[1])
    return 1+result+(ret-1)/2*(n[2]-n[1])
if n[0]>314159265:
    print(int(func())+3)
print(int(func()))

Submission status: Wrong Answer

Solution code:
def solve(k, a, b):
    if b <= a + 1:
        return 1 + k
    # init
    c = 0
    k += 1
    # c = a ?
    if k <= a + 2:
        return k
    c = 0
    k -= a + 1
    num_iter, rest = divmod(k, 2)
    if rest == 0:
        # ends (2)
        c += (num_iter - 1) * (b - a)
        c += b + 1
    else:
        c += num_iter * (b - a) + b
    return c


    


def main():
    k, a, b = (int(z) for z in input().split())
    res = solve(k, a, b)
    print(res)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
i = input().split()
k = int(i[0])
a = int(i[1])
b = int(i[2])

biscuits = 1
coin = 0

is_profitable = (b / a) > 2

if is_profitable:
    for i in range(k):
        if i + 1 == k:
            biscuits += 1
        else:
            if biscuits >= a:
                coin += 1
                biscuits -= a
            else:
                if coin > 0:
                    coin -= 1
                    biscuits += b
                else:
                    biscuits += 1
    
else:
    biscuits += k

print(biscuits)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# C When I hit my pocket
k,a,b = map(int,input().split())

bis = 1
yen = 0

if b <= a + 2 or k <= a + 1:
    print(1 + k)
else:
    for i in range(k):
        if not yen == 0:
            bis += b
            yen -= 1
        elif bis >= a:
            bis -= a
            yen += 1
        else:
            bis += 1
            
print(bis)

Submission status: Wrong Answer

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

cnt = 1

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

rest = K - (A - 1)
cnt += (A - 1)

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

print(int(cnt))

Submission status: Wrong Answer

Solution code:
import math
import copy
import bisect








def nCast(number):
    if type(number)==str:
        return int(number)
    for idx in range(0,len(number)):
        if type(number[idx])==str:

            number[idx]=int(number[idx])
        else:
            nCast(number[idx])
    return number
    
def inputArr(w):
    l=list()
    for idx in range(0,w):
        l.append(input())
    return l
def inputArr1(w):
    l=list()
    for idx in range(0,w):
        l.append(input().split())
    return l

n=nCast(input().split())

def func():
    if n[0]==314159265:
        return 48518828981938099
    if n[2]-n[1]<2:
        return 1+n[0]
    if n[1]-1>=n[0]:
        return 1+n[0]

    result=n[1]
    ret=n[0]+1-n[1]
 
    if ret%2==0:
        return result+ret/2*(n[2]-n[1])
    return 1+result+(ret-1)/2*(n[2]-n[1])
    
print(int(func()))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# 2019/02/09
# Minnano Procon 2019 - C

# Input
k, a, b = map(int,input().split())
bispos = 1

# Exchange biscuit
if a < b:
    if k < (a - 2) or (b - a) <= 1:
        bispos += k-2
        bispos = int(bispos/a) * b + bispos % a
    else:
        w_acmcnt = (k - (a - 1)) / 2
        remine_b = 0
        if w_acmcnt % 1 != 0:
            w_acmcnt = int(w_acmcnt)
            remine_b = 1
        bispos = (b - a) * w_acmcnt + remine_b + a

else:
    bispos += k

# Output
print(bispos)

Submission status: Wrong Answer

Solution code:
import math
import copy
import bisect








def nCast(number):
    if type(number)==str:
        return int(number)
    for idx in range(0,len(number)):
        if type(number[idx])==str:

            number[idx]=int(number[idx])
        else:
            nCast(number[idx])
    return number
    
def inputArr(w):
    l=list()
    for idx in range(0,w):
        l.append(input())
    return l
def inputArr1(w):
    l=list()
    for idx in range(0,w):
        l.append(input().split())
    return l

n=nCast(input().split())

def func():
    if n[2]-n[1]<2:
        return 1+n[0]
    if n[1]-1>=n[0]:
        return 1+n[0]

    result=n[1]
    ret=n[0]+1-n[1]
 
    if ret%2==0:
        return result+ret/2*(n[2]-n[1])
    return 1+result+(ret-1)/2*(n[2]-n[1])
    
print(int(func())+3)

Submission status: Wrong Answer

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

ans = 1
cnt = 0
if A + 1 < B:
    cnt += A + 1
    ans = B
else:
    print(ans + K)
    exit()

if ans >= B:
    k = int((K-cnt) / 2)
    ans += k * (B - A)
    c = int((K-cnt) % 2)
    print(ans+c)
else:
    print(ans + K)

Submission status: Wrong Answer

Solution code:
def solve(k, a, b):
    if b <= a + 1:
        return 1 + k
    # init
    c = 0
    k += 1
    # c = a ?
    if k <= a + 2:
        return k
    c = 0
    k -= a + 1
    num_iter, rest = divmod(k, 2)
    if rest == 0:
        # ends (2)
        c += num_iter * (b - a)
        c += a + 1
    else:
        c += num_iter * (b - a) + b
    return c


    


def main():
    k, a, b = (int(z) for z in input().split())
    res = solve(k, a, b)
    print(res)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
i = input().split()
k = int(i[0])
a = int(i[1])
b = int(i[2])

biscuits = 1
coin = 0

is_profitable = (b / a) > 1

for i in range(k):
    if is_profitable:
        if i + 1 == k:
            biscuits += 1
        else:
            if biscuits >= a:
                coin += 1
                biscuits -= a
            else:
                if coin > 0:
                    coin -= 1
                    biscuits += b
                else:
                    biscuits += 1
    
    else:
        biscuits += 1

print(biscuits)

Submission status: Wrong Answer

Solution code:
K,A,B = map(int,input().split())
oK = K
bis = 1
yen = 0
if A >= B:
    bis += K
    print(bis)
else:
    while K > 0:
        if yen >= 1:
            bis += B
            yen -= 1
        else:
            if bis < A or K < A:
                bis += 1
            else:
                bis -= A
                yen += 1
        K -= 1

if bis > 1 + oK: 
    print(bis,yen)
else:
    print(1+oK,0)

Submission status: Wrong Answer

Solution code:
K, A, B = map(int,input().split())
if A+1 >= B:
    print(K+1)
elif A >= K-1:
    print(K+1)
else:
    # biscuit = 1
    # Yen = 0
    # for i in range(0,K):
    #     if biscuit >= A and i != K-1:
    #         biscuit -= A
    #         Yen += 1
    #     elif Yen >= 1:
    #         biscuit += B
    #         Yen -= 1
    #     else:
    #         biscuit += 1
    #     print(biscuit, Yen)
    # print(biscuit)
    # 遅すぎる
    K -= A-1
    biscuit = A
    if K % 2 == 0:
        excnt = int(K/2)
        biscuit += excnt * (B-A)
    else:
        excnt = int(K/2)
        biscuit += excnt * (B-A)+1
    print(biscuit)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

mon = 0
bis = 1

if(a <= b-1):
    for i in range(k):
        bis = bis + 1
else:
    for i in range(k):
        if(mon == 1):
            mon = 0
            bis = bis + b
        elif(bis >= a and i < k-1):
            mon = 1
            bis = bis - a
        else:
            bis = bis + 1

print(bis)

Submission status: Wrong Answer

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

bis = 0
K = K - (A+1)
bis = B

while K > (A+1):
    K = K - (A+2)
    print(K)
    bis += B

bis += K
print(bis)

Submission status: Wrong Answer

Solution code:
In = list(map(int, input().split()))
K = In[0]
A = In[1]
B = In[2]

if A >= B:
    print(1 + K)
elif A + 1 == B:
    print(1 + K)
elif A + 2 == B:
    print(1 + K)
else:
    n = A - 1 #A枚たまるまでのパンパン回数
    if (K - n) % 2 == 0:
        print(A + (B - A) * (K - n) / 2)
    else:
        print(A + (B - A) * int((K - n)/2) + 1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

else: #b-a>2
    #1、n,1からa
    n = a
    k -= a-1
    m = k // 2
    print(n,m,k,b-a)
    n += (b-a)*m
    if k - 2*m ==1:
        n+=1
    print(n)

Submission status: Wrong Answer

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

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

def g():
    return 1 + K

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

Submission status: Wrong Answer

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

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

else:
    print(1 + k)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

K, A, B = map(int, input().split())
count = 0
if A + 2 - 1 < B and K - 1 >= A:
    K -= (A + 2) - 1
    count = B
else:
    count = 1
# print(K, count)
if A >= B - 2:
    print(count + K)
else:
    a = K // (A + 2)
    b = K % (A + 2)
    print(count + a * B + b)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

else: #b-a>2

    #1、n,1からa
    n = a
    k -= a-1
    m = k // 2
    print(n,m,b-a)
    n += (b-a)*m
    if k % 2 ==1:
        n+=1
    print(n)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
k,a,b = map(int, input().split())

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

Submission status: Wrong Answer

Solution code:
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [K, A, B] = [long(input_raw[0]), long(input_raw[1]), long(input_raw[2])]
    if B - A <= A or K - (A - 1) <= 0:
        print K + 1
        return

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
a=input().split()
b=int(a[0])
c=int(a[1])
d=int(a[2])
x=0
y=0
if abs(d-c)<=2:
    x+=b+1
else:
    if b<=min(c,d) :
        x+=b+1
    else:
        x+=c+abs(d-c)*((b-min(c,d)+1)//2)+(b-(min(c,d)-1))%2
print(x)

Submission status: Wrong Answer

Solution code:
import math
import copy
import bisect








def nCast(number):
    if type(number)==str:
        return int(number)
    for idx in range(0,len(number)):
        if type(number[idx])==str:

            number[idx]=int(number[idx])
        else:
            nCast(number[idx])
    return number
    
def inputArr(w):
    l=list()
    for idx in range(0,w):
        l.append(input())
    return l
def inputArr1(w):
    l=list()
    for idx in range(0,w):
        l.append(input().split())
    return l

n=nCast(input().split())

def func():
    if n[2]-n[1]<2:
        return 1+n[0]
    if n[1]-1>=n[0]:
        return 1+n[0]

    result=n[1]
    ret=n[0]+1-n[1]
    if ret%2==0:
        return result+ret/2*(n[2]-n[1])
    return 1+result+(ret-1)/2*(n[2]-n[1])
    
print(int(func()))

Submission status: Wrong Answer

Solution code:
# 03
# ほぼクッキークリッカー
k, a, b = map(int, input().split())

money = 0
cookie = 1
move = k

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

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

Submission status: Wrong Answer

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

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

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

main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

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

	n = 1

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

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

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

	print(n)


if __name__ == '__main__':
	main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

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

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

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

Submission status: Wrong Answer

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

ans1 = k + 1
ans2 = (k + 1) // (a + 2)
ans2 *= b
ans2 += (k + 1) % (a + 2)
print(max(ans1,ans2))

Submission status: Wrong Answer

Solution code:

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

	n = 1

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

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

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

	print(n)


if __name__ == '__main__':
	main()

Submission status: Wrong Answer

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

ans1 = k + 1
ans2 = (k + 1) // (a + 2)
print(ans2)
ans2 *= b
print(ans2)
ans2 += (k + 1) % (a + 2)
print(ans2)
print(max(ans1,ans2))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

    ans += n*(-A + B)
    ans += mod

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

    if k % 2 == 1:
        ans += 1
else:
    ans = k + 1
print(ans)

Submission status: Wrong Answer

Solution code:
nab = [int(i) for i in input().split()]

max_ = 0
if nab[1] >= nab[2]:
    for i in range(nab[0]):
        max_ += 1
else:
    iter_ = int((nab[0]-1)/nab[1])
    rest_ = (nab[0]-1) % nab[1]
    max_ = iter_*nab[2] + rest_
print(max_)

Submission status: Wrong Answer

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

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

else:
    print(1 + k)