Problem:


Score : 100 points

Problem Statement

ButCoder Inc. runs a programming competition site called ButCoder. In this site, a user is given an integer value called rating that represents his/her skill, which changes each time he/she participates in a contest. The initial value of a new user's rating is 0, and a user whose rating reaches K or higher is called Kaiden ("total transmission"). Note that a user's rating may become negative.

Hikuhashi is a new user in ButCoder. It is estimated that, his rating increases by A in each of his odd-numbered contests (first, third, fifth, ...), and decreases by B in each of his even-numbered contests (second, fourth, sixth, ...).

According to this estimate, after how many contests will he become Kaiden for the first time, or will he never become Kaiden?

Constraints

1 ≤ K, A, B ≤ 10^{18}

All input values are integers.

Input

Input is given from Standard Input in the following format:

K A B

Output

If it is estimated that Hikuhashi will never become Kaiden, print -1. Otherwise, print the estimated number of contests before he become Kaiden for the first time.

Sample Input 1

4000 2000 500

Sample Output 1

5

Each time Hikuhashi participates in a contest, his rating is estimated to change as 0 → 2000 → 1500 → 3500 → 3000 → 5000 → … After his fifth contest, his rating will reach 4000 or higher for the first time.

Sample Input 2

4000 500 2000

Sample Output 2

-1

Each time Hikuhashi participates in a contest, his rating is estimated to change as 0 → 500 → -1500 → -1000 → -3000 → -2500 → … He will never become Kaiden.

Sample Input 3

1000000000000000000 2 1

Sample Output 3

1999999999999999997

The input and output values may not fit into 32-bit integers.



Sample input:
4000 2000 500


Sample output:
5

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LIM(): return list(map(lambda x:int(x) - 1, sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def LIRM(n): return [LIM() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
mod = 1000000007



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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

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

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

Submission status: Accepted

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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def getinputdata():

    # 配列初期化
    array_result = []
    
    data = input()

    array_result.append(data.split(" "))

    flg = 1

    try:


        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:


        return array_result

arr_data = getinputdata()

k = int(arr_data[0][0])
a = int(arr_data[0][1])
b = int(arr_data[0][2])

cnt = a - b

rate = a

if rate >= k:
    
    print(1)
    
elif cnt==0:

    print(-1)
else:
    
    if (k-rate) % cnt == 0:
        
        num = (k-rate) // cnt 
        
        print(1+ num*2)
    
    else:
        
        num = ((k-rate) // cnt) + 1
        
        if num>=1 :
        
            print(num*2+1)
        
        else:
            
            print(-1)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

if B >= A:
    print("-1")
    exit()

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

Submission status: Accepted

Solution code:
import decimal

from math import ceil


def solve(k, a, b):
    if k <= a:
        return 1
    if a <= b:
        return -1
    ka = decimal.Decimal(k - a)
    ab = decimal.Decimal(a - b)
    return ceil(ka / ab) * 2 + 1


print(solve(*map(int, input().split())))

Submission status: Accepted

Solution code:
# -*- coding:utf-8 -*-
from decimal import *
import math
k,a,b = map(int, input().split())
if a >= k:
    print(1)
else:
    if a <= b:
        print(-1)
    else:
        print(2*math.ceil(Decimal(k-a)/Decimal(a-b))+1)

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def M(n): return ModInt(n)
def MI(): return M(I())


def main():
    k,a,b = LI()
    if k <= a:
        return 1
    if a <= b:
        return -1
    t = a-b
    r = int((k-a) / t)
    for i in range(r-10,r+10):
        if i*t + a >= k:
            return i*2+1

    return -1



print(main())

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import math
K, A, B = list(map(int, input().split()))
 
if (A >= K):
    print('1')
    sys.exit()
elif (A - B) <= 0:
    print('-1')
    sys.exit()
d = A-B
p = K-A
q = p//d
if ((p % d) != 0):
    q += 1
print(int(2*q + 1))

Submission status: Accepted

Solution code:
import math
from decimal import *

numbers = [int(i) for i in input().split()]

diff = numbers[1] - numbers[2]

if numbers[0] <= numbers[1]:
    print("1")
elif diff <= 0:
    print("-1")
else:
    print(math.ceil(Decimal(numbers[0] - numbers[1]) / diff) * 2 + 1)

Submission status: Accepted

Solution code:
import sys
import math
K, A, B = list(map(int, input().split()))
 
if (A >= K):
    print('1')
    sys.exit()
elif (A - B) <= 0:
    print('-1')
    sys.exit()
d = A-B
p = K-A
q = int(p//d)
if ((p % d) != 0):
    q += 1
print(str(2*q + 1))

Submission status: Accepted

Solution code:
import math

k, a, b = map(int, input().split())
inc = a - b
if k <= a:
    print(1)
elif inc < 0:
    if k <= a:
        print(1)
    else:
        print(-1)
elif inc == 0:
    print(-1)
else:
    from decimal import *
    getcontext().prec = 500
    print(math.ceil(Decimal(k-a) / Decimal(inc))*2+1)

Submission status: Accepted

Solution code:
# coding:utf-8

K, A, B = map(int, raw_input().split())
if K <=A:
    print 1

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

Submission status: Accepted

Solution code:
if __name__ == "__main__":
    K,A,B = map(int, input().split())
    left = 0
    right = 2 ** 100
    if A >= K:
        print (1)
        exit()
    if B >= A:
        print (-1)
        exit()
    while (right - left > 1):
        med = (right + left) // 2
        res = (A - B) * med
        if res >= K:
            right = med
        else:
            left = med
    # print ((A - B) * right)
    res = 2 * right
    for x in range(max(1, res - 100), res+10):
        a1 = x // 2
        a2 = x - a1
        tmp = A * a2 - B * a1
        if tmp >= K:
            print (x)
            exit()

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

    if A >= K:
        print(1)
        exit()
    elif A <= B:
        print(-1)
        exit()

    n, m = divmod(K - A, A - B)
    ans = n * 2 + 1
    a = -A
    b = B
    while m > 0:
        m += b
        a, b = b, a
        ans += 1
    print(ans)

main()

Submission status: Accepted

Solution code:
K,A,B = map(int,input().split())
if A >= K:
    print(1)
elif A > B:
    #n = math.ceil((K-A) / (A-B))
    n = (K-A-1) // (A-B) + 1
    print(2*n + 1)
else:
    print(-1)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
def solve(k, a, b):
    if a - b <= 0:
        if k <= a:
            return 1
        else:
            return -1
    return 1 + (k - a + (a - b) - 1) // (a - b) * 2
k, a, b = map(int, input().split())
print(solve(k, a, b))

Submission status: Accepted

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

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

x = (K-B-1)/(A-B)+1
print 2*x-1

Submission status: Runtime Error

Solution code:
ceil = lambda a, b: -(-a // b)

K, A, B = map(int, input().split())
if A >= K:
    print(1)
    exit()
p = A - B
if p < 0:
    print(-1)
    exit()

ans = 1
ans += ceil(K - A, A - B) * 2
print(ans)

Submission status: Runtime Error

Solution code:
from itertools import accumulate as ac
n=int(input())
a,b=[],[]
for i in range(n):
    x,s=map(int,input().split())
    a.append(x)
    b.append(s)
r=[0]+list(ac(b))
l=r[:]
for i in range(n):
    r[i]+=-a[i]
    l[i+1]+=-a[i]
q,d=r[0],0
for i in range(1,n+1):
    d=max(l[i]-q,d)
    q=min(q,r[i-1])
print(d)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:

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

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
K,N,M=map(int,input().split())
if N>= K:
  print(i)
elif N-M>0:
  print(2*K//(N-M)+1)
else:
  print(-1)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
s =input().split()
a=0
b=0
while a<int(s[0]) :
    b+=1
    a+=int(s[1])
    if a>int(s[0]) :
        break
    b+=1
    a=a-int(s[2])
    if a<0 :
        break
if a<0 :
    print(-1)
if a>int(s[0]) :
    print(int(b)

Submission status: Runtime Error

Solution code:
def getinputdata():

    # 配列初期化
    array_result = []
    
    data = input()

    array_result.append(data.split(" "))

    flg = 1

    try:


        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:


        return array_result

arr_data = getinputdata()

k = int(arr_data[0][0])
a = int(arr_data[0][1])
b = int(arr_data[0][2])

cnt = a - b

rate = a

if rate >= k:
    
    print(1)
    
else:
    
    if (k-rate) % cnt == 0:
        
        num = (k-rate) // cnt 
        
        print(1+ num*2)
    
    else:
        
        num = ((k-rate) // cnt) + 1
        
        if num>=1 :
        
            print(num*2+1)
        
        else:
            
            print(-1)

Submission status: Runtime Error

Solution code:
def getinputdata():

    # 配列初期化
    array_result = []
    
    data = input()

    array_result.append(data.split(" "))

    flg = 1

    try:


        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:


        return array_result

arr_data = getinputdata()

k = int(arr_data[0][0])
a = int(arr_data[0][1])
b = int(arr_data[0][2])

cnt = (k-a) // (a-b)

#print(cnt)

if a-b<0 and k>a:

    print(-1)

else:
    if ((k-a) % (a-b) == 0):

        print(1 + cnt * 2)

    else:

        print(1 + (cnt + 1) * 2)

Submission status: Runtime Error

Solution code:
def getinputdata():

    # 配列初期化
    array_result = []
    
    data = input()

    array_result.append(data.split(" "))

    flg = 1

    try:


        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:


        return array_result

arr_data = getinputdata()

k = int(arr_data[0][0])
a = int(arr_data[0][1])
b = int(arr_data[0][2])

cnt = (k-a) // (a-b)

#print(cnt)

if k > a:

    print(-1)

else:
    if ((k-a) % (a-b) == 0):

        print(1 + cnt * 2)

    else:

        print(1 + (cnt + 1) * 2)

Submission status: Runtime Error

Solution code:
def getinputdata():

    # 配列初期化
    array_result = []
    
    data = input()

    array_result.append(data.split(" "))

    flg = 1

    try:


        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:


        return array_result

arr_data = getinputdata()

k = int(arr_data[0][0])
a = int(arr_data[0][1])
b = int(arr_data[0][2])

cnt = (k-a) // (a-b)

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

if (A >= K):
    print('1')
    sys.exit()
elif (A - B) <= 0:
    print('-1')
    sys.exit()
d = A-B
p = K-A
q = int(p//d)
if ((p % d) != 0):
    q += 1
print(str(2*q + 1))

Submission status: Runtime Error

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

if (A >= K):
    print('1')
    sys.exit()
elif (A - B) <= 0:
    print('-1')
    sys.exit()
d = A-B
p = K-A
q = int(p/d)
if ((p % d) != 0):
    q += 1
print(str(2*q + 1))

Submission status: Runtime Error

Solution code:
import math
from decimal import *

k, a, b = map(int, input().split())
inc = a - b
if inc < 0:
    if k <= a:
        print(1)
    else:
        print(-1)
    exit()

getcontext().prec = 500
print(math.ceil(Decimal(k-a) / Decimal(inc))*2+1)

Submission status: Runtime Error

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

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

 p = K-A
 q = math.ceil(p/d)
 if p % d != 0:
     q += 1
 print(int(2*q + 1))

Submission status: Runtime Error

Solution code:
import math

k, a, b = map(int, input().split())
p = 0
inc = a - b

if inc < 0:
    if k >= a:
        print(1)
    else:
        print(-1)
    exit()
print(math.ceil((k-a) / inc)*2+1)

Submission status: Runtime Error

Solution code:
# coding:utf-8

K, A, B = map(int, raw_input().split())
n=0

if A <= B:
    print '-1'
else:
    for i in range(K+1):
        if (A*(n+2)-B*(n+1))>K and (A*(n+1)-B*n)<K:
            print 2*n+3
        n+=1

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import math
K,A,B=map(int,input().split())
ini=K-A
up=A-B
print(2*math.ceil(ini/up) +1)

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
def solve(k, a, b):
    if a - b <= 0 and a < k:
        return -1
    return 1 + (k - a + (a - b) - 1) // (a - b) * 2
k, a, b = map(int, input().split())
print(solve(k, a, b))