Koto Municipal Subway

Koto Municipal Subway

Koto City is a famous city whose roads are in a grid pattern, as shown in the figure below. The roads extending from north to south and the roads extending from east to west are lined up at intervals of 1 km each. Let Koto station at the southwestern intersection of Koto city be (0, 0), and mark x km east and y km north from it as (x, y) (0 ≤ x, y). ).

<image>

In anticipation of an increase in tourists due to the Olympic Games to be held five years later, the city has decided to build a new subway line starting from Koto station. Currently, we are planning to lay a rail to Shin-Koto station, which will be newly constructed as the next station after Koto station. The rail will be laid straight from Koto station to Shin-Koto station. Therefore, when the location of Shin-Koto station is (x, y), the length of the rail is √ (x2 + y2). The cost of laying the rail is the same as the length of the laid rail. Even if the rail length is a decimal number such as 1.5km, the cost is also 1.5.

The location (x, y) of Shin-Koto station has not been decided yet, and we plan to make it a location that meets the following conditions.

* It is an intersection. That is, x and y are integers, respectively.
* The shortest distance walked along the road from Koto station is exactly D. That is, x + y = D is satisfied.



Among the above two conditions, select the location of Shin-Koto station so that the difference between the rail budget E and the rail cost set by the city | √ (x2 + y2) --E | is minimized. Here, | A | represents the absolute value of A. Your job is to create a program that outputs the difference between the cost and budget for laying rails when the Shin-Koto station was constructed as described above.

Input

The input consists of multiple data sets, and the number of data sets contained in one input is 100 or less. The format of each data set is as follows.

> D E

D (1 ≤ D ≤ 100) is an integer that represents the shortest distance when walking along the road from Koto station to Shin-Koto station. E (1 ≤ E ≤ 100) is an integer representing the budget for rail construction.

The end of the input is indicated by a line of two zeros separated by a blank.

Output

For each data set, output the difference between the cost and budget when laying the rail so as to satisfy the problem condition in one line. The answer must have an absolute error greater than 10-3. Note that if you do not output a line break at the end of each line, or if you output unnecessary characters, it will be judged as an incorrect answer.

Sample Input


twenty one
7 5
7 6
7 7
76 5
8 41
0 0

Output for Sample Input


0.4142135624
0
0.0827625303
0
48.7401153702
33

Hint

In the first data set, as shown in the figure below, an intersection 2 km along the road from Koto station is a candidate for a place to build Shin-Koto station.

<image>

When Shin-Koto station is constructed at each intersection, the difference between the cost for laying the rail and budget 1 is as follows.

* (2, 0): | √ (22 + 02) --1 | = 1.0
* (1, 1): | √ (12 + 12) --1 | = 0.4142135623 ...
* (0, 2): | √ (02 + 22) --1 | = 1.0



Therefore, the difference between the cost and the budget is minimized when the construction is done in (1, 1).





Example

Input

2 1
7 5
7 6
7 7
76 5
8 41
0 0


Output

0.4142135624
0
0.0827625303
0
48.7401153702
33

Source: aizu | Difficulty: UNKNOWN_DIFFICULTY


Solutions:
def main():
	while 1:
		(d, e) = map(int, input().split())
		if d == e == 0:
			break
		x = d
		y = 0
		ans = abs(d - e)
		while y != d:
			a = abs((x ** 2 + y ** 2) ** 0.5 - e)
			ans = min(a, ans)
			x -= 1
			y += 1
		print(ans)
main()


while True:
	(d, e) = map(int, input().split())
	if d == 0:
		break
	ans = abs(d - e)
	for x in range(1, d):
		y = d - x
		ans = min(ans, abs((x ** 2 + y ** 2) ** 0.5 - e))
	print('{:.4f}'.format(ans))


import math
while 1:
	(d, e) = map(int, input().split())
	if d == 0:
		break
	ans = 1000000000.0
	for i in range(d):
		x = i
		y = d - x
		dist = math.sqrt(x ** 2 + y ** 2)
		ans = min(ans, abs(dist - e))
	print(ans)


import math
while True:
	(D, E) = map(int, input().split())
	if D == 0 and E == 0:
		break
	ans = float('inf')
	for x in range(D + 1):
		for y in range(D + 1):
			if x + y == D:
				ans = min(abs(math.sqrt(x * x + y * y) - E), ans)
	print(ans)


import math
import sys

def main():
	while True:
		(d, e) = map(int, input().split())
		ans = sys.maxsize
		if not d and (not e):
			return
		for x in range(d + 1):
			y = d - x
			ans = min(ans, abs(math.sqrt(float(x) ** 2 + float(y) ** 2) - e))
		print(ans)
main()


import math
while True:
	(d, e) = map(int, input().split())
	if d == 0:
		break
	print(min([abs(e - math.sqrt(i ** 2 + (d - i) ** 2)) for i in range(d // 2 + 1)]))


import math
while 1:
	(d, e) = map(int, input().split())
	if d == 0:
		break
	ans = 10 ** 9
	for x in range(d + 1):
		y = d - x
		diff = abs(math.sqrt(x ** 2 + y ** 2) - e)
		if diff < ans:
			ans = diff
	print(ans)


while True:
	(d, e) = map(int, input().split())
	if d == 0:
		break
	print(min(map(lambda x: abs((x ** 2 + (d - x) ** 2) ** 0.5 - e), range(d + 1))))


import math
while 1:
	(d, e) = map(int, input().split())
	if d == 0 and e == 0:
		break
	Min = 9999999999
	for i in range(d + 1):
		y = d - i
		ans = abs(math.sqrt(i ** 2 + y ** 2) - e)
		Min = min(Min, ans)
	print(Min)


import math
while True:
	(d, e) = map(int, input().split())
	sa = max(d, e)
	if d == 0 and e == 0:
		break
	for i in range(math.floor(d / 2) + 1):
		if math.fabs(math.sqrt(i ** 2 + (d - i) ** 2) - e) < sa:
			sa = math.fabs(math.sqrt(i ** 2 + (d - i) ** 2) - e)
	print(sa)


from math import fabs, sqrt
while True:
	(D, E) = map(int, input().split())
	if D == 0 and E == 0:
		break
	ans = 1000000000.0
	for x in range(D):
		y = D - x
		dist = fabs(sqrt(x ** 2 + y ** 2) - E)
		ans = min(ans, dist)
	print(ans)


from math import hypot
while True:
	(d, e) = map(int, input().split())
	if d == 0:
		exit()
	ans = 100000.0
	for x in range(d + 1):
		y = d - x
		ans = min(ans, abs(hypot(x, y) - e))
	print(ans)


while 1:
	(d, e) = map(int, input().split())
	if d == 0:
		break
	r = []
	for x in range(d // 2 + 1):
		r += [abs((x ** 2 + (d - x) ** 2) ** 0.5 - e)]
	print('%.6g' % min(r))


import math
while 1:
	(d, e) = list(map(int, input().strip().split()))
	if d == e == 0:
		break
	diff = 20000
	for x in range(d + 1):
		y = d - x
		if diff > math.fabs(math.sqrt(x ** 2 + y ** 2) - e):
			diff = math.fabs(math.sqrt(x ** 2 + y ** 2) - e)
	print(diff)


while True:
	(d, e) = map(int, input().split())
	if d == 0:
		break
	ans = 10 ** 5
	for x in range(d + 1):
		y = d - x
		ans = min(ans, abs((x ** 2 + y ** 2) ** 0.5 - e))
	print(ans)


while 1:
	(d, e) = map(int, input().split())
	if d == 0:
		break
	data = []
	for i in range(0, 101):
		for j in range(0, 101):
			data.append((abs((i * i + j * j) ** 0.5 - e), i, j))
	for p in sorted(data):
		if p[1] + p[2] == d:
			print(p[0])
			break


while True:
	(D, E) = map(int, input().split())
	if D == E == 0:
		break
	print('{:.020f}'.format(min((abs(pow(x ** 2 + (D - x) ** 2, 0.5) - E) for x in range(D + 1)))))


import math

def get_two_int():
	two_int = input().split()
	for i in range(2):
		two_int[i] = int(two_int[i])
	return two_int

def get_diff_set_between_cost_and_budget(walk_distance, budget):
	diff_set = set()
	max_x = walk_distance // 2 + 1
	for x in range(max_x):
		y = walk_distance - x
		abs_diff = abs(calculate_cost(x, y) - budget)
		diff_set.add(abs_diff)
	return diff_set

def calculate_cost(x, y):
	cost = math.sqrt(x ** 2 + y ** 2)
	return cost
while True:
	(walk_distance, budget) = get_two_int()
	if walk_distance == 0:
		break
	diff_set = get_diff_set_between_cost_and_budget(walk_distance, budget)
	min_num = min(diff_set)
	print(min_num)


while 1:
	(d, e) = map(int, input().split())
	mi = ((d // 2) ** 2 + (d - d // 2) ** 2) ** 0.5
	if d == e == 0:
		break
	if d <= e:
		print(e - d)
	elif mi >= e:
		print(f'{mi - e:.5f}')
	else:
		ans = float('inf')
		for i in range(d // 2):
			mi = abs((i ** 2 + (d - i) ** 2) ** 0.5 - e)
			ans = min(ans, mi)
		print(f'{ans:.5f}')


import math
while True:
	(D, E) = map(int, input().split())
	if D + E == 0:
		break
	i = 0
	ans = 101
	while True:
		if i > D:
			break
		j = 0
		while True:
			if i + j > D:
				break
			if i + j == D:
				ans = min(ans, abs(math.sqrt(i ** 2 + j ** 2) - E))
			j += 1
		i += 1
	print(ans)


from math import sqrt
while True:
	(d, e) = map(int, input().split())
	if d == e == 0:
		break
	mn = 10000
	for i in range(d // 2 + 1):
		mn = min(mn, abs(sqrt(i ** 2 + (d - i) ** 2) - e))
	print(mn)


import math
while 1:
	(D, E) = map(int, input().split())
	if not D and (not E):
		break
	f = lambda l: abs(math.sqrt(l[0] ** 2 + l[1] ** 2) - E)
	m = min(map(f, [[i, D - i] for i in range(math.ceil((D + 1) / 2))]))
	print(m)


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 ** 10
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 main():
	rr = []
	while True:
		(d, e) = LI()
		if d == 0:
			break
		r = inf
		for i in range(d // 2 + 1):
			j = d - i
			tr = abs(e - (i ** 2 + j ** 2) ** 0.5)
			if r > tr:
				r = tr
		rr.append(r)
	return '\n'.join(map(str, rr))
print(main())


while True:
	(D, E) = map(int, input().split())
	if D == 0:
		break
	else:
		ans = 100
		for i in range(D // 2 + 1):
			A = (i ** 2 + (D - i) ** 2) ** (1 / 2)
			a = abs(A - E)
			if a < ans:
				ans = a
			else:
				pass
		print(ans)


while True:
	(d, e) = map(int, input().split())
	if d == e == 0:
		break
	r = []
	for x in range(int(d / 2 + 1)):
		r += [abs((x ** 2 + (d - x) ** 2) ** 0.5 - e)]
	print(min(r) if min(r) % 1 != 0 else int(min(r)))


while 1:
	(d, e) = map(int, input().split())
	if d == 0:
		break
	a = []
	for i in range(d):
		a.append(abs((i ** 2 + (d - i) ** 2) ** 0.5 - e))
	print(min(a))


while 1:
	(d, e) = map(int, input().split())
	if d == 0:
		break
	print('%.6g' % min((abs((x ** 2 + (d - x) ** 2) ** 0.5 - e) for x in range(d // 2 + 1))))


import math
while True:
	(D, E) = map(int, input().split())
	if D == 0:
		break
	ans = 10 ** 5
	for x in range(0, D + 1):
		y = D - x
		if x > y:
			break
		score = abs(E - math.sqrt(x * x + y * y))
		ans = min(score, ans)
	print(ans)