There is a polyline going through points (0, 0) – (x, x) – (2x, 0) – (3x, x) – (4x, 0) – ... - (2kx, 0) – (2kx + x, x) – .... 

We know that the polyline passes through the point (a, b). Find minimum positive value x such that it is true or determine that there is no such x.


-----Input-----

Only one line containing two positive integers a and b (1 ≤ a, b ≤ 10^9).


-----Output-----

Output the only line containing the answer. Your answer will be considered correct if its relative or absolute error doesn't exceed 10^{ - 9}. If there is no such x then output  - 1 as the answer.


-----Examples-----
Input
3 1

Output
1.000000000000

Input
1 3

Output
-1

Input
4 1

Output
1.250000000000



-----Note-----

You can see following graphs for sample 1 and sample 3.  [Image]  [Image]

Difficulty: competition

Starter code:

Solutions:
n,m=map(int,input().split())
if m>n:print(-1)
else:
	q=int((1.+n/m)/2.)
	v=(m+n)/(2*q)
	print(v)

a,b = list(map(int,input().split()))
if b > a:
    print(-1)
else:
    try:
        x= 100000000000
        k = int((a+b)/2/b)
        if k != 0:
            x = (a+b)/2/k
        k = int((a-b)/2/b)
        if k != 0:
            x = min(x,(a-b)/2/k)
        print("%.9f"%x)
    except:
        print(-1)


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

def solve(a, b):
    if a < b:
        return -1
    if b == 0:
        return -1
    if a == b:
        return a
    k0 = (a - b)//(2 * b)
    if k0 == 0:
        x0 = float('inf')
    else:
        x0 = (a - b)/(2 * k0)
    k1 = (a + b)//(2 * b)
    x1 = (a + b)/(2 * k1)
    return min(x0, x1)

print(solve(a, b))


x, y = [int(x) for x in input().split()]
n1 = x + y
ans1 = -1
ans2 = -1
if n1 // y  - (n1 // y % 2) != 0:
    ans1 = n1 / (n1 // y  - (n1 // y % 2))
n2 = x + y    
if n2 // y  - (n2 // y % 2) != 0:
    ans2 = n2 / (n2 // y  - (n2 // y % 2))
print(min(ans1, ans2))

from decimal import *
import math
getcontext().prec=50


a,b=list(map(Decimal, input().split()))
if b>a:
    print(-1)
else:
    cur=-1
    if (a+b)%2==0:
        cur=(a+b)//2
    else:
        cur=(a+b)/Decimal(2)
    print(cur/math.floor(cur/b))



from decimal import *
import math
getcontext().prec=50
a,b=map(Decimal, input().split())
print ( -1 if b>a else(Decimal((a+b)/2)/math.floor(Decimal((a+b)/2)/b)))

import math
a,b=map(float, input().split())
print ( -1 if b>a else(((a+b)/2)/math.floor(((a+b)/2)/b)))

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

def run1(x, y):
    if x < y:
        return -1;
    cst = (x - y) * 0.5;
    l = 1; r = 1000000001;
    ans = - 1.0;
    while(l <= r):
        m = (l + r) >> 1;
        now = cst / m;
        if now >= y:
            ans = now;
            l = m + 1;
        else:
            r = m - 1;
    return ans;

def run2(x, y):
    cst = (x + y) * 0.5;
    l = 1; r = 1000000001;
    ans = - 1.0;
    while(l <= r):
        m = (l + r) >> 1;
        now = cst / m;
        if( now >= y ):
            ans = now;
            l = m + 1;
        else:
             r = m - 1;
    return ans;

x, y = list(map(int, input().split()));
p = run1(x, y);
q = run2(x, y);

ans = - 1.0;

if(ans < 0 or (p > 0 and p < ans) ):
    ans = p;
if(ans < 0 or (q > 0 and q < ans) ):
    ans = q;
print (ans)




#!/usr/bin/env python
# 579C_polyline.py - Codeforces.com/problemset/problem/579/C by Sergey 2015

import unittest
import sys

###############################################################################
# Polyline Class (Main Program)
###############################################################################


class Polyline:
    """ Polyline representation """

    def __init__(self, test_inputs=None):
        """ Default constructor """

        it = iter(test_inputs.split("\n")) if test_inputs else None

        def uinput():
            return next(it) if it else sys.stdin.readline().rstrip()

        # Reading single elements
        [self.a, self.b] = list(map(int, uinput().split()))

    def calculate(self):
        """ Main calcualtion function of the class """

        result = float(1)

        if self.a < self.b:
            return "-1"

        if self.a == self.b:
            return str("{0:.12f}".format(self.b))

        r1 = (self.a + self.b) / (2 * int((self.a + self.b) / (2 * self.b)))
        d = (2 * int((self.a - self.b) / (2 * self.b)))
        result = r1 if d == 0 else min(r1, (self.a - self.b) / d)
        return str("{0:.12f}".format(result))

###############################################################################
# Unit Tests
###############################################################################


class unitTests(unittest.TestCase):

    def test_single_test(self):
        """ Polyline class testing """

        # Constructor test
        test = "3 1"
        d = Polyline(test)
        self.assertEqual(d.a, 3)
        self.assertEqual(d.b, 1)

        # Sample test
        self.assertEqual(Polyline(test).calculate(), "1.000000000000")

        # Sample test
        test = "1 3"
        self.assertEqual(Polyline(test).calculate(), "-1")

        # Sample test
        test = "4 1"
        self.assertEqual(Polyline(test).calculate(), "1.250000000000")

        # My tests
        test = "103 100"
        self.assertEqual(float(Polyline(test).calculate()), 101.5)
        test = "299 100"
        self.assertEqual(float(Polyline(test).calculate()), 199.5)
        test = "310 100"
        self.assertEqual(float(Polyline(test).calculate()), 102.5)

        # Time limit test
        # self.time_limit_test(5000)

    def time_limit_test(self, nmax):
        """ Timelimit testing """
        import random
        import timeit

        # Random inputs
        test = str(nmax) + " " + str(nmax) + "\n"
        numnums = [str(i) + " " + str(i+1) for i in range(nmax)]
        test += "\n".join(numnums) + "\n"
        nums = [random.randint(1, 10000) for i in range(nmax)]
        test += " ".join(map(str, nums)) + "\n"

        # Run the test
        start = timeit.default_timer()
        d = Polyline(test)
        calc = timeit.default_timer()
        d.calculate()
        stop = timeit.default_timer()
        print(("\nTimelimit Test: " +
              "{0:.3f}s (init {1:.3f}s calc {2:.3f}s)".
              format(stop-start, calc-start, stop-calc)))

def __starting_point():

    # Avoiding recursion limitaions
    sys.setrecursionlimit(100000)

    if sys.argv[-1] == "-ut":
        unittest.main(argv=[" "])

    # Print the result string
    sys.stdout.write(Polyline().calculate())

__starting_point()

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

a, b = list(map(int, input().split()))
print(-1 if b > a else (a+b)/2/((a+b)//(2*b)))


def main():
    a, b = list(map(int, input().split()))
    n = a // b
    if n:
        n -= n + 1 & 1
        print("{:.12f}".format((a + b) / (n + 1)))
    else:
        print("-1")


def __starting_point():
    main()

__starting_point()

import sys
from math import sqrt

x, y = [int(x) for x in sys.stdin.readline().split()]

if y > x:
    print(-1)
else:
    s = (x + y) / 2
    r = (x - y) / 2
    ans = min(s / int(s / y), r / int(r / y)) if r >= y else s / int(s / y)
    print(ans)


a, b = list(map(int, input().split()))
if a < b:
    print(-1)
elif a == b:
    print(a)
else:
    ku = (a - b) // (2 * b)
    kd = (a + b) // (2 * b)
    xd = (a + b) / (2 * kd)
    if ku == 0:
        print(xd)
    else:
        xu = (a - b) / (2 * ku)
        print(min(xu, xd))


ent = input().split()
x = int(ent[0])
y = int(ent[1])

qn = ((x + y)/(2 * y)).__trunc__()
if qn == 0:
    print(-1)
else:
    n = (x + y)/(2 * qn)
    print(n)


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

if b - a == 0:
    print( '%.12f' % (b))

elif int((a - b)/(2 * b)) == 0 and int((a + b)/(2 * b)) == 0:
    print(-1)
else:
    if int((a - b)/(2 * b)) != 0 and int((a + b)/(2 * b)) != 0:
        print( '%.12f' % (min(((a - b) / (2 * int((a - b)/(2 * b)))),((a + b) / (2 * int((a + b)/(2 * b)))))))
    elif int((a - b)/(2 * b)) == 0 and int((a + b)/(2 * b)) != 0:
        print( '%.12f' % (((a + b) / (2 * int((a + b)/(2 * b))))))








a, b = list(map(int, input().split()))
if b > a:
    print(-1)
else:
    x1 = a + b
    x = b
    print(x1 / (2 * (x1 // (2 * x))))


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

#!/usr/bin/env python3
import collections, itertools, fractions, functools, heapq, math, queue

def solve():
  a, b = list(map(int, input().split()))
  if a < b:
      return -1
  return (a+b)/(2*((a+b)//(2*b)))

def __starting_point():
  print(solve())


__starting_point()

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

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


from math import floor

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

if (a < b):
    print(-1)
else:
    print((a + b) / (2 * floor(((a + b) / (2 * b)))))