Arkadiy has lots square photos with size a × a. He wants to put some of them on a rectangular wall with size h × w. 

The photos which Arkadiy will put on the wall must form a rectangular grid and the distances between neighboring vertically and horizontally photos and also the distances between outside rows and columns of photos to the nearest bound of the wall must be equal to x, where x is some non-negative real number. Look on the picture below for better understanding of the statement.

 [Image] 

Arkadiy haven't chosen yet how many photos he would put on the wall, however, he want to put at least one photo. Your task is to determine the minimum value of x which can be obtained after putting photos, or report that there is no way to put positive number of photos and satisfy all the constraints. Suppose that Arkadiy has enough photos to make any valid arrangement according to the constraints.

Note that Arkadiy wants to put at least one photo on the wall. The photos should not overlap, should completely lie inside the wall bounds and should have sides parallel to the wall sides.


-----Input-----

The first line contains three integers a, h and w (1 ≤ a, h, w ≤ 10^9) — the size of photos and the height and the width of the wall.


-----Output-----

Print one non-negative real number — the minimum value of x which can be obtained after putting the photos on the wall. The absolute or the relative error of the answer must not exceed 10^{ - 6}.

Print -1 if there is no way to put positive number of photos and satisfy the constraints.


-----Examples-----
Input
2 18 13

Output
0.5

Input
4 4 4

Output
0

Input
3 4 3

Output
-1



-----Note-----

In the first example Arkadiy can put 7 rows of photos with 5 photos in each row, so the minimum value of x equals to 0.5.

In the second example Arkadiy can put only 1 photo which will take the whole wall, so the minimum value of x equals to 0.

In the third example there is no way to put positive number of photos and satisfy the constraints described in the statement, so the answer is -1.

Difficulty: VERY_HARD
Tags: Number theory

Starter code:

Solutions:
def gcd(n, m):
	if m == 0:
		return n
	else:
		return gcd(m, n % m)
(a, h, w) = map(int, input().split())
g = gcd(a + h, a + w)
s = (a + w) // g
t = (w // a + 1) // s * s - 1
if t <= 0:
	print(-1)
else:
	print('%.10lf' % ((w - t * a) / (t + 1)))


def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)
(a, h, w) = map(int, input().split())
g = gcd(a + h, a + w)
t = (a + w) // g
q = (w // a + 1) // t * t - 1
if q <= 0:
	print(-1)
else:
	print('%.9lf' % ((w - q * a) / (q + 1)))


def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)

def main():
	(a, h, w) = map(int, input().split())
	x = gcd(a + h, a + w)
	y = (a + w) // x
	z = (w // a + 1) // y * y - 1
	if z <= 0:
		print('-1')
	else:
		print('%.10lf' % ((1.0 * w - z * a) / (z + 1)))
main()


def gcd(x, y):
	if y == 0:
		return x
	else:
		return gcd(y, x % y)
(A, H, W) = map(int, input().split())
G = gcd(A + H, A + W)
S = (A + W) // G
T = (W // A + 1) // S * S - 1
if T <= 0:
	print(-1)
else:
	print('%.10lf' % ((W - T * A) / (T + 1)))


(a, h, w) = (int(x) for x in input().split())
if h == w:
	if a < h:
		n = w // a
		x = (w - a * n) / (n + 1)
		print(x)
	elif a == h:
		print(0)
	else:
		print(-1)
else:
	for i in range(100):
		if h > w:
			(w, h) = (h, w)
		if w > h + a * 2:
			w = w - h - a
	if h > w:
		(w, h) = (h, w)
	m = h // a
	s = (w - h) // a
	r = 0
	if m < s or s == 0:
		for i in range(m, 0, -1):
			x = (h - a * i) / (i + 1)
			w1 = w - x
			a1 = a + x
			q = w1 % a1
			if q < 1e-08 or a1 - q < 1e-07:
				r = 1
				break
		if r == 0:
			print(-1)
		else:
			print(x)
	else:
		for i in range(s, 0, -1):
			x = (w - h - i * a) / i
			w1 = w - x
			a1 = a + x
			q = w1 % a1
			if q < 1e-08:
				r = 1
				break
		if r == 0:
			print(-1)
		else:
			print(x)


def gcd(x, y):
	if x % y == 0:
		return y
	return gcd(y, x % y)
(a, h, w) = input().split()
a = int(a)
h = int(h)
w = int(w)
g = gcd(h + a, w + a)
if g < a or h < a or w < a:
	print('-1')
else:
	print(g / (g // a) - a)