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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

biscuits = 1
is_profitable = (b / a) > 2

if is_profitable:
    x = a - biscuits
    if x > 0:
        biscuits += x
        k -= x

    n = math.floor(k / 2)

    for i in range(n):
        if biscuits >= a:
            biscuits += b - a
        else:
            biscuits += 2
else:
    biscuits += k

if k % 2 > 0 and is_profitable:
    biscuits += 1

print(biscuits)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if B-A > 2:
    flag = 1
"""
cont1 = 0
cont2 = 0

for i in range(K):
    if cont1 == 1:
        cont1-=1
        continue
   if cont2 == 1:
        cont2-=1
        continue
   
    
    if bis >= A and K-2>i and flag == 1:
        bis = bis-A+B
        cont1 = 1
        continue

    bis += 1
else:
    print(bis)
"""

# A+1 turn => bis += B
# (K-1)//(A+1) * B + (K-1)%(A+1)
# X -> A -> B 2turn

saisyo = K-A

if flag == 1 and saisyo//2==1:
    print((saisyo//2+1)*(B-A)+saisyo%2-1)
    exit()
print(((saisyo//2+1)*(B-A))+A) if flag==1 else print(K+1)

Submission status: Wrong Answer

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

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

else:
    cookie = B
    K = K-A-1

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

Submission status: Wrong Answer

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

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

ans += K

print(ans)

Submission status: Wrong Answer

Solution code:
s = input().split()
K = int(s[0])
A = int(s[1])
B = int(s[2])
 
bis = 1
 
if float(B/A) > 2:
  change = 1
else:
  change = 0
 
if change == 0:
  bis = bis + K
else:
  i = A - 1
  bis  = A
  k = K - i
  bis += (k//2)*(B-A)
  bis += k %2
print(bis)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

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

def main():
    bisk_num = 1
    yen = 0
    for k in range(K):
        if (yen > 0):
            yen -= 1
            bisk_num += B
        elif (bisk_num >= A and B > K - k + A and k < K - 1):
            yen += 1
            bisk_num -= A
        else:
            bisk_num += 1
    print(bisk_num)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

bis = 1

if float(B/A) > 2:
  change = 1
else:
  change = 0

if K > 1 and K > A:
  if change == 0:
    bis +=K
  else:
    i = A - 1
    bis  = A
    k = K - i
    bis += (k//2)*(B-A)
    bis += k %2
elif K == 1:
  pass
else:
  bis +=K
print(bis)

Submission status: Wrong Answer

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

if a >= b or a > k+1:
    bi = bi + k
    print(str(bi))
else:
    while bi < a :
        bi += 1
        k -= 1
        if bi == a :
            bi = 0
            mo += 1
        if k == 0:
            break
    print(str(bi + b * mo))

Submission status: Wrong Answer

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

bis = 1

if float(B/A) > 2:
  change = 1
else:
  change = 0

if K > 1 and K > A+1:
  if change == 0:
    bis +=K
  else:
    i = A - 1
    bis  = A
    k = K - i
    bis += (k//2)*(B-A)
    bis += k %2
elif K == 1:
  pass
else:
  bis +=K
print(bis)

Submission status: Wrong Answer

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

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

print(res)

Submission status: Wrong Answer

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

bis = 1

if float(B/A) > 2:
  change = 1
else:
  change = 0

if K > 1 and K > A-1:
  if change == 0:
    bis +=K
  else:
    i = A - 1
    bis  = A
    k = K - i
    bis += (k//2)*(B-A)
    bis += k %2
elif K == 1:
  pass
else:
  bis +=K
print(bis)

Submission status: Wrong Answer

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

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

else:
    cookie = B
    K = K-A-1

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

else:
    cookie = B
    K = K-A-1

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
k,a,b = map(int ,input().split())
x = 1
c = 0
for i in range(k):
    if i == k-1 and c == 0:
        x += 1
        continue
    if a >= b or x < a and c == 0:
        x += 1
        continue
    elif c >= 1 and a < b:
        x += b
        c = c - 1
        continue
    elif x >= a and i <= k-2 and a < b:
        x = x - a
        c += 1
        continue
    
print(x)

Submission status: Wrong Answer

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

if a >= b:
    bi = bi + k
    print(str(bi))
elif a > k+1 :
    print(str(k+1))
else:
    while bi < a :
        bi += 1
        k -= 1
        if k == 0:
            break
        if bi == a :
            bi -= a
            mo += 1
    print(str(bi + b * mo))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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 + 3

else:
    bispos += k

# Output
print("{:.0f}".format(bispos))

Submission status: Wrong Answer

Solution code:
k, a, b = map(int, input().split())
if 2 < (b - 2):
    k = k - (a - 1)
    c = 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:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
k,a,b = map(int, input().split())

if a >= b:
  print(k+1)
elif k==1:
  print(b)
elif k==2:
  print(b)
elif k<=a:
  print(k+1)
else:
  t=((k+1)//(a+2))
  r=(k+1)-t*(a+2)
  if a < (b-a):
    nn = (k+1)-a
    print(nn//2*(b-a)+a+((k+1)-a)%2) 
  else:
    print(max(t*b+r,k+1))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if a >= b:
    bi = bi + k
    print(str(bi))
elif a > k+1 :
    print(str(k+1))
else:
    while k > 0:
        while bi < a :
            bi += 1
            k -= 1
            if k == 0:
                break
        if bi == a :
            bi -= a
            mo += 1
    print(str(bi + b * mo))

Submission status: Wrong Answer

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

else:
    bis+=K

print(bis+1)

Submission status: Wrong Answer

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

bis = 1

if float(B/A) > 2:
  change = 1
else:
  change = 0

if K > 1:
  if change == 0:
    bis = bis + K
  else:
    i = A - 1
    bis  = A
    k = K - i
    bis += (k//2)*(B-A)
    bis += k %2
print(bis)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if (B - A) / 2 <= 1 or K < A + 2: # ビスケットを叩くのが良い
    ans = (K + 1)
else: # ビスケットを交換した方が良い
    n = (K - A - 1)
    if n % 2 == 0:
        ans = (B + (B-A)*n/2)
    else:
        ans = (B + (B-A)*int(n/2) + 1)

if ans < (10**15):
    print(ans)
else:
    print('{0}{1}'.format(int(ans/(10**15)), int(ans % (10**15))))

# 48518828981938096
# 48518828981938099

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("{:.0f}".format(bispos))

Submission status: Wrong Answer

Solution code:
def func():
    pass


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

    # i = 0
    # c = 1
    # while i < k:
    #     if c >= a and (k - i - 1) >= 2:
    #         # print("2:", i, c)
    #         c = c - a + b
    #         i += 1
    #     else:
    #         # print("3:", i, c)
    #         c += 1
    #     i += 1
    #
    # print(max(c, k))

    x = k - (a - 1)
    y = x // 2

    # 2,3 を y回繰り返す
    # y * (b-a)まい増える

    # print(x, y, y * (b - a) + (k - ((a - 1) + 2 * y)))
    q = (y * (b - a) + (k - ((a - 1) + 2 * y)))
    print(max((q + a), k))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

bis = 1

if float(B/A) > 2:
  change = 1
else:
  change = 0

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

Submission status: Wrong Answer

Solution code:
import math
K,A,B = map(int, input().split())
cookie = 0
 
# if K < A - 1 or B - A <  A + 1 or B - A < 2:
#     print(K + 1)
# 
# else:
cookie = B
K = K-A-1

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8
import sys
import collections
# 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()
    n = 1
    m = 0
    i = 0

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

    else:
        p = a + 2
        num = (k - (a - 1)) // p
        pp = (b - a) * num
        print(p)
        print(pp)
        print(num)

        i = a + 1
        n = b
        n += pp
        i += num * p
        print(n, i)

        while i < k:
            print(i)
            if m >= 1:
                n += b * m
                m = 0
                print("4だよ", n, m)

            elif i == k - 1:
                n += 1
                print("最後だよ", n, m)

            elif a > n:
                print(n)
                u = a - n
                n += u
                i += u - 1
                print("1だよ", n, m)

            elif a <= n:
                u = n // a
                n -= u * a
                m += u
                i += u
                print(u)
                print("2だよ", n, m)
            else:
                n += 1
                print("3だよ", n, m)
            i += 1
        print(n)


main()

Submission status: Wrong Answer

Solution code:
def function(K, A, B):
	bis = 1
	if B - A > 1:
		b = K - (A+1)
		c = (int(b/2))*(B-A)
		d = b%2
		print(c + d + B)

	else:
		print(K + 1)

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:
K, A, B = map(int, input().split())

def f(K, A, B):
    if A >= B - 2 or K <= A:
        return K + 1
    
    # then A < K and A < B

    # break cookies for (A-1) times
    K -= (A - 1)
    if K % 2 == 0:
        return A + (B - A) * (K / 2)
    else:
        return 1 + A + (B - A) * (K // 2)
    
ans = f(K, A, B)
print('%d'%ans)

Submission status: Wrong Answer

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

f=a-1+1+1
s=a+1+1

d=(k-f)//s
m=(k-f)%s

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

Submission status: Wrong Answer

Solution code:

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

Submission status: Wrong Answer

Solution code:
a=[]#入力画面の二文字を別々の文字に格納
a=input().split(" ")
K=int(a[0])
A=int(a[1])
B=int(a[2])
d=K-A
b=B+1
if A+1>=B :
    x=1+K
    print(x)
elif A>=K:
    print(K+1)
elif d%2==0:
    if K==A+2:
        print(B+1)
    else:
        x1=(d-2)*(B-A)*(1/2)+B+1
        print(int(x1))
elif d%2==1:
    if K==A+1:
        print(B)
    else:
        x2=(d-1)*(B-A)*(1/2)+B
        print(int(x2))

Submission status: Wrong Answer

Solution code:
k,a,b=map(int,input().split())
i=-1
ans=0
e=0
if a>=b-2:
    print(ans+1+k)
else:
    while i<k:
        if i+a<=k:
            ans+=a
            i+=a
        else:
            ans+=k-i
            break
        if i<=k-2:
            e+=1
            i+=2
        else:
            ans+=1
            break
    print(ans+e*(b-a))

Submission status: Wrong Answer

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

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

print(res)

Submission status: Wrong Answer

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

if (k == 1):
    print(2)
    exit()

if (b <= (a + 1)):
    print(k + 1)
    exit()
else:
    tmp1 = k - (a - 1)
    sabun = b - a

    if (tmp1 % 2 == 0):
        bis = ((tmp1 / 2) - 1) * sabun + b
    else:
        bis = ((tmp1 // 2) - 1) * sabun + b + 1

    print(bis)

Submission status: Wrong Answer

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

if K > A  or B - A >  A :
    
    cookie = B
    K = K-A-1

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

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(200000)


def input():
    return sys.stdin.readline()[:-1]


def ii(t: type = int):
    return t(input())


def il(t: type = int):
    return list(map(t, input().split()))


def imi(N: int, t: type = int):
    return [ii(t) for _ in range(N)]


def iml(N: int, t: type = int):
    return [il(t) for _ in range(N)]


def solve():
    K, A, B = il()
    ka = K - (A - 1)
    ans = (ka // 2 - 1) * (B-A) + B
    return max(K + 1, ans)


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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
k,a,b = map(int, input().split())

if a >= b:
  print(k+1)
elif k==1:
  print(b)
elif k==2:
  print(b)
else:
  t=((k+1)//(a+2))
  r=(k+1)-t*(a+2)
  if a < (b-a):
    nn = (k+1)-a
    print(nn//2*(b-a)+a+((k+1)-a)%2)
  else:
    print(max(t*b+r,k+1))

Submission status: Wrong Answer

Solution code:
K, A, B = map(int, input().split())
if K <= 2:
    print(3)
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:
# -*- coding: utf-8 -*-
import sys
# ----------------------------------------------------------------
# Use Solve Function

def solve(lines):
    K,A,B = map(int, lines.pop(0).split(' '))
    if A >= B:
        print(K+1)
        sys.exit(0)
    elif B - A <= 2:
        print(K+1)
        sys.exit(0)

    if K < A+1:
        print(K+1)
        sys.exit(0)
    elif K == A+1 and K > B:
        print(K+1)
        sys.exit(0)

    K -= A+1
    res = B

    n = int(K / 2)
    res += n*(B-A)
    K -= n

    if K == 1:
        res += 1

    print(res)

#
# main
#
lines = [x.strip() for x in sys.stdin.readlines()]

#
# solve !!
#
solve(lines)

Submission status: Wrong Answer

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

if K > A  or B - A <  A  :
    
    cookie = B
    K = K-A-1

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if (B - A) / 2 <= 1 or K < A + 2: # ビスケットを叩くのが良い
    ans = (K + 1)
else: # ビスケットを交換した方が良い
    n = (K - A - 1)
    print(n)
    if n % 2 == 0:
        ans = (B + (B-A)*n/2)
    else:
        ans = (B + (B-A)*int(n/2) + 1)

if ans < 10^15:
    print(ans)
else:
    print('{0}{1}'.format(int(ans/100000000000000), int(ans % 100000000000000)))

# 48518828981938096
# 48518828981938099

Submission status: Wrong Answer

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

bis = 1

if float(B/A) > 2:
  change = 1
else:
  change = 0

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

Submission status: Wrong Answer

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

need_turns = A + 1 + 1  # 交換に必要なターン
first_need_turns = need_turns - 1

if A + 2 > B or K < first_need_turns:  # 交換せずにビスケットを叩き続ける方が得
    print(1 + K)
    exit()

ans = B  # 一度交換した
K -= (need_turns - 1)

# print("{}, {}".format(K, ans))

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

print(ans)

Submission status: Wrong Answer

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

if a < b - 2:
    if k > (a + 2):
        res = b + ((k - (a+2)) // 2) * (b-a) + ((k - (a+2)) % 2)
    else:
        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())
ans=0
if a+1<k and b>a+2:
  k=k-(a+1)
  ans+=b
  mul,mod=divmod(k,2)
  ans+=(mul)*(b-a)
  ans+=mod
  print(ans)
else:
  print(1+k)

Submission status: Wrong Answer

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



if A + 1 < B:
    bis = 1
    add = B - A # 増える数
    moving = (K//A) -1 #交換可能回数
    #print(moving)
    if moving > 0:
        #print("m")
        bis = B
        K-=A+1
    else:
        print(K+1)
        exit()
    #print(bis)
    
    bis+=add*(K // 2)
    if K % 2 != 0:
        bis+=1
    #print(bis,moving)
    print(bis)
    
else:
    print(K+1)

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
    else:
        # a->bコンボが利潤を生み続けるパターン
        rest = 1 + k - a
        if rest >= 0:
            if rest % 2 == 0:
                sum = a + ((diff) * (rest / 2))
            else:
                # 最後1回はコンボができないので、叩くパターン
                sum = a + ((diff) * ((rest - 1) / 2)) + 1
        else:
            sum = k + 1
                
print(int(sum))

Submission status: Wrong Answer

Solution code:
k,a,b=map(int,input().split())
ans=0
if a+1<k and b>a+2:
  k=k-(a+1)
  ans+=b
  mul,mod=divmod(k,2)
  ans+=(mul)*(b-a)
  ans+=mod
  print(ans)
else:
  print(ans+k)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if K ==1:
    print(2)
else:


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


    else:
        cookie = B
        K = K-A-1

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

Submission status: Wrong Answer

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

def f(k,a,b):
    bsk = 1
    if (a+1)>=b or (k<(a+1)):
        bsk += k
        print(bsk)
        return
    else:
        k -= (a-1)
        bsk = a
    
    if k>=2:
        if k%2==0:
            bsk += (b-a)*(k/2)
        else:
            bsk += (b-a)*((k-1)/2)+1
    
        print(int(bsk))
        return
    else:
        bsk +=k
        print(int(bsk))
        return
    
    
f(k,a,b)

Submission status: Wrong Answer

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