Carol is currently curling.

She has n disks each with radius r on the 2D plane. 

Initially she has all these disks above the line y = 10^100.

She then will slide the disks towards the line y = 0 one by one in order from 1 to n. 

When she slides the i-th disk, she will place its center at the point (x_{i}, 10^100). She will then push it so the disk’s y coordinate continuously decreases, and x coordinate stays constant. The disk stops once it touches the line y = 0 or it touches any previous disk. Note that once a disk stops moving, it will not move again, even if hit by another disk. 

Compute the y-coordinates of centers of all the disks after all disks have been pushed.


-----Input-----

The first line will contain two integers n and r (1 ≤ n, r ≤ 1 000), the number of disks, and the radius of the disks, respectively.

The next line will contain n integers x_1, x_2, ..., x_{n} (1 ≤ x_{i} ≤ 1 000) — the x-coordinates of the disks.


-----Output-----

Print a single line with n numbers. The i-th number denotes the y-coordinate of the center of the i-th disk. The output will be accepted if it has absolute or relative error at most 10^{ - 6}.

Namely, let's assume that your answer for a particular value of a coordinate is a and the answer of the jury is b. The checker program will consider your answer correct if $\frac{|a - b|}{\operatorname{max}(1, b)} \leq 10^{-6}$ for all coordinates.


-----Example-----
Input
6 2
5 5 6 8 3 12

Output
2 6.0 9.87298334621 13.3370849613 12.5187346573 13.3370849613



-----Note-----

The final positions of the disks will look as follows: [Image] 

In particular, note the position of the last disk.

Difficulty: MEDIUM
Tags: Mathematics

Geometry

Implementation

Complete search
Skill types: Complete search
Expected Time Complexity: O(N^2)

Starter code:

Solutions:
from math import sqrt

def main():
	(n, r) = map(float, input().split())
	d = r * 2.0
	d2 = d * d
	l = []
	for x in map(float, input().split()):
		(le, ri, h) = (x - d, x + d, r)
		for (u, v) in l:
			if le <= u <= ri:
				w = x - u
				y = v + sqrt(d2 - w * w)
				if h < y:
					h = y
		l.append((x, h))
		print(h, end=' ')
main()


from math import sqrt
(n, r) = map(int, input().split())
bubbles_x = list(map(int, input().split()))
bubbles_y = []
for i in range(n):
	if i == 0:
		bubbles_y.append(r)
		continue
	else:
		current_bubble = bubbles_x[i]
		check_order_bubbles = bubbles_x[0:i]
		length = r
		for (j, current_conflicting_bubble) in enumerate(check_order_bubbles):
			temp = abs(current_bubble - current_conflicting_bubble)
			if temp > r * 2:
				continue
			elif temp == r * 2:
				length = max(length, bubbles_y[j])
			else:
				length = max(length, bubbles_y[j] + sqrt((2 * r) ** 2 - temp ** 2))
		bubbles_y.append(length)
print(*bubbles_y)


from math import sqrt

class Point:

	def __init__(self, x, y):
		self.x = x
		self.y = y

class Circle:

	def __init__(self, center, r):
		self.center = center
		self.r = r

	def stop_point(self, disk):
		x_i = disk.center.x
		delta = (self.r + disk.r) ** 2 - (x_i - self.center.x) ** 2
		if delta >= 0:
			y_i = self.center.y + sqrt(delta)
		else:
			y_i = disk.r
		return y_i

class Disks:

	def __init__(self, circles=[]):
		self.circles = circles

	def __contains__(self, circle):
		return circle in self.circles

	def __iter__(self):
		for circle in self.circles:
			yield circle

	def append(self, circle):
		self.circles.append(circle)

	def list_ys(self):
		return [disk.center.y for disk in self.circles]

class Input:

	def __init__(self):
		first_line = input().split(' ')
		second_line = input().split(' ')
		self.NUMBER_OF_DISKS = int(first_line[0])
		self.RADIO = int(first_line[1])
		self.X_POSITIONS = [float(x) for x in second_line]

class Output:

	def __init__(self, list_of_ys):
		self.output_content = ' '.join([str(y) for y in list_of_ys])

	def print_output(self):
		print(self.output_content)

	def __str__(self):
		return self.output_content

	def __repr__(self):
		return self.__str__()

def main():
	input_exercise = Input()
	disks = Disks()
	for x in input_exercise.X_POSITIONS:
		max_y = input_exercise.RADIO
		disk = Circle(Point(x, 1000), input_exercise.RADIO)
		for c in disks:
			y = c.stop_point(disk)
			max_y = y if y > max_y else max_y
		disk.center.y = max_y
		disks.append(disk)
	output = Output(disks.list_ys())
	output.print_output()
main()


import math
input1 = '6 2'
input2 = '5 5 6 8 3 12'

def distance(x1, y1, x2, y2):
	return math.sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2)

def y_stop(x1, y1, x2, r):
	return y1 + math.sqrt((r * 2) ** 2 - (x1 - x2) ** 2)

def inRangeTuples(x, tuples):
	inRange = []
	for t in tuples:
		if abs(x - t[0]) <= 2 * r:
			inRange.append(t)
	return inRange
(n, r) = map(int, input().split())
x = [int(y) for y in input().split()]
result_y = [r]
result_xy = [(x[0], r)]
for xi in x[1:]:
	closest_tuple = None
	for t in inRangeTuples(xi, result_xy):
		if not closest_tuple:
			closest_tuple = t
		elif y_stop(closest_tuple[0], closest_tuple[1], xi, r) < y_stop(t[0], t[1], xi, r):
			closest_tuple = t
	if closest_tuple:
		newy = y_stop(closest_tuple[0], closest_tuple[1], xi, r)
		result_xy.append((xi, newy))
		result_y.append(newy)
	else:
		result_xy.append((xi, r))
		result_y.append(r)
print(*result_y, sep=' ')


import math
(nb_disks, radius) = [int(x) for x in input().split()]
coord_x = [int(x) for x in input().split()]
coord_y = [radius] * nb_disks
for d in range(1, nb_disks):
	for d2 in range(d):
		dist_x = abs(coord_x[d] - coord_x[d2])
		if dist_x > 2 * radius:
			continue
		hauteur = coord_y[d2] + math.sqrt((2 * radius) ** 2 - dist_x ** 2)
		if hauteur > coord_y[d]:
			coord_y[d] = hauteur
print(' '.join(map(str, coord_y)))


(n, r) = map(int, input().split())
arr = [int(i) for i in input().split()]
ans = []
ar = []
ans.append(r)
ar.append(arr[0])
for i in range(1, n):
	an = r
	flag = False
	temp = -1
	for j in range(len(ar)):
		if ar[j] <= arr[i] + 2 * r and ar[j] >= arr[i] - 2 * r:
			an = max(an, ans[j] + (pow(2 * r, 2) - pow(arr[i] - ar[j], 2)) ** 0.5)
			flag = True
	ans.append(an)
	ar.append(arr[i])
for i in range(len(ans)):
	print(ans[i], end=' ')


import math
(n, r) = map(int, input().split())
x = list(map(int, input().split()))
y = [r]
for i in range(1, n):
	_y = r
	for j in range(i):
		if 4 * r * r >= (x[i] - x[j]) * (x[i] - x[j]):
			_y = max(_y, y[j] + math.sqrt(4 * r * r - (x[i] - x[j]) * (x[i] - x[j])))
	y.append(round(_y, 6))
print(' '.join(map(str, y)))


import math
(n, r) = map(int, input().split())
xs = list(map(int, input().split()))
ys = [r] * n
for i in range(1, n):
	for j in range(i):
		if xs[j] > xs[i] + 2 * r or xs[j] < xs[i] - 2 * r:
			continue
		y = ys[j] + math.sqrt(4 * r * r - (xs[j] - xs[i]) * (xs[j] - xs[i]))
		if y > ys[i]:
			ys[i] = y
print(' '.join(map(str, ys)))


def f(x1, x2, y2):
	t = 4 * r * r - (x1 - x2) ** 2
	if t >= 0:
		return y2 + t ** 0.5
	return r
(n, r) = map(int, input().split())
print(r)
(*a,) = map(int, input().split())
cor = [[a[i], r] for i in range(n)]
for i in range(1, n):
	cor[i][1] = max((f(cor[i][0], cor[j][0], cor[j][1]) for j in range(i)))
	print(cor[i][1])


from math import sqrt
(n, r) = map(int, input().split())
r2 = r ** 2
(*X,) = map(int, input().split())
Y = [0] * n
ans = []
for i in range(n):
	y = r
	for j in range(i):
		diff = abs(X[i] - X[j])
		if diff == 2 * r:
			y = max(y, Y[j])
		elif diff < 2 * r:
			y = max(y, sqrt(4 * r2 - diff ** 2) + Y[j])
	Y[i] = y
	ans.append('%.010f' % Y[i])
print(*ans)


from math import sqrt
(n, r) = map(int, input().split())
a = [float(x) for x in input().split()]
centre = [r]
for i in range(1, n):
	(maxx, t) = (r, 0)
	for j in range(i):
		if abs(a[j] - a[i]) <= 2 * r:
			t = centre[j] + sqrt(4 * r * r - pow(a[j] - a[i], 2))
			maxx = max(maxx, t)
	centre.append(maxx)
for i in range(n):
	print(centre[i], end=' ')


import math
[n, r] = list(map(int, input().split()))
X = list(map(int, input().split()))
Y = [0] * n
touching = [-1] * n
Y[0] = r
for i in range(1, len(X)):
	k = -1
	md = -1
	for j in range(i - 1, -1, -1):
		if X[i] - 2 * r <= X[j] and X[j] <= X[i] + 2 * r:
			d = Y[j] + math.sqrt((2 * r) ** 2 - (X[i] - X[j]) ** 2)
			if d > md:
				k = j
				md = d
	if k != -1:
		Y[i] = round(Y[k] + math.sqrt((2 * r) ** 2 - (X[i] - X[k]) ** 2), 11)
	else:
		Y[i] = r
for y in Y:
	print(round(y, 11), end=' ')
print()


from math import sqrt
(n, r) = list(map(int, input().split(' ')))
down = []
clean = list(map(int, input().split(' ')))
down.append(r)
for i in range(1, n):
	new_y = r
	for j in range(i):
		if abs(clean[i] - clean[j]) <= 2 * r:
			potential_y = down[j] + sqrt(4 * r ** 2 - (clean[i] - clean[j]) ** 2)
			new_y = max(new_y, potential_y)
	down.append(new_y)
down = [str(element) for element in down]
print(' '.join(down))


(k, r) = map(int, input().split())
S = list(map(int, input().split()))
Used = []
Answer = []
for i in S:
	delta = r
	for j in range(len(Used)):
		if abs(i - Used[j]) <= 2 * r:
			rass = abs(i - Used[j])
			delta = max(delta, Answer[j] + ((2 * r) ** 2 - rass ** 2) ** 0.5)
	Answer.append(delta)
	Used.append(i)
print(' '.join(map(str, Answer)))


import math

def pythag(a, h):
	return math.sqrt(h ** 2 - a ** 2)

def main():
	(n, r) = map(int, input().split())
	arr = list(map(int, input().split()))
	prev = []
	for i in range(n):
		x = arr[i]
		y = r
		for (a, b) in prev:
			if abs(x - a) <= 2 * r:
				y = max(y, b + pythag(a - x, 2 * r))
		prev.append((x, y))
	for i in range(n):
		print(prev[i][1], end=' ')
	print('')
main()


(n, r) = map(int, input().split())
x = [int(i) for i in input().split()]
ans_y = [r]
for i in range(1, n):
	curr_x = x[i]
	stat = True
	pos = []
	index_of_check = 0
	for j in range(0, i):
		if x[j] - 2 * r <= curr_x <= x[j] + 2 * r:
			pos.append(j)
			stat = False
	if stat:
		ans_y.append(r)
		continue
	else:
		y_max = 0
		for j in pos:
			x_c = x[j]
			y_c = ans_y[j]
			delta_x = (curr_x - x_c) ** 2
			delta_y = (4 * r ** 2 - delta_x) ** 0.5
			new_y = delta_y + y_c
			y_max = max(new_y, y_max)
		ans_y.append(y_max)
for i in ans_y:
	print(i, end=' ')


from math import sqrt

def findCollision(x, y, m, r):
	j = []
	for i in range(m):
		if abs(x[m] - x[i]) <= 2 * r:
			j.append((i, y[i] + sqrt(4 * r * r - (x[m] - x[i]) ** 2)))
	if not j:
		return None
	j.sort(key=lambda x: -x[1])
	return j[0]
(n, r) = list(map(int, input().rstrip().split()))
x = list(map(int, input().rstrip().split()))
y = [0 for _ in range(n)]
y[0] = r
for i in range(1, n):
	j = findCollision(x, y, i, r)
	if j is None:
		y[i] = r
	else:
		y[i] = j[1]
print(' '.join(map(str, y)))


read = lambda : map(int, input().split())
(n, r) = read()
x = list(read())
y = [0] * n
for i in range(n):
	cur = r
	for j in range(i):
		if 2 * r >= abs(x[i] - x[j]):
			cur = max(cur, y[j] + (4 * r * r - (x[i] - x[j]) ** 2) ** 0.5)
	y[i] = cur
print(*y)


import sys
f = sys.stdin
(n, r) = list(map(int, f.readline().split()))
xs = list(map(int, f.readline().split()))
import math
xy_before = []
ans = []
for x in xs:
	max_y = r
	for (bx, by) in xy_before:
		if abs(x - bx) <= 2 * r:
			if max_y < by + math.sqrt((2 * r) ** 2 - (x - bx) ** 2):
				max_y = by + math.sqrt((2 * r) ** 2 - (x - bx) ** 2)
	ans.append(max_y)
	xy_before.append((x, max_y))
print(' '.join(map(str, ans)))


import math
n = 0
r = 0
x = []

def io():
	global n, r, x
	(n, r) = map(int, input().split(' '))
	x = list(map(int, input().split(' ')))

def main():
	io()
	y = [r] * n
	for i in range(0, len(x), 1):
		x1 = x[i]
		for j in range(0, i, 1):
			if i == j:
				continue
			x2 = x[j]
			if abs(x2 - x1) <= 2 * r:
				y[i] = max(y[i], y[j] + math.sqrt(4 * r * r - (x1 - x2) * (x1 - x2)))
	for i in range(0, len(y), 1):
		print(y[i], end=' ')
	print()
main()


(n, r) = list(map(int, input().split()))
disks = list(map(int, input().split()))
new_disks = []
for i in range(n):
	y2 = r
	x2 = disks[i]
	for j in range(i):
		(x1, y1) = new_disks[j]
		a = r * r * 4 - (x2 - x1) ** 2
		if a < 0:
			continue
		else:
			y2 = max(y2, a ** 0.5 + y1)
	new_disks.append([x2, y2])
for i in new_disks:
	print(i[1], end=' ')


(n, r) = map(int, input().split())
x = list(map(int, input().split()))
y = []
for i in range(n):
	s = []
	for j in range(i):
		if abs(x[i] - x[j]) < 2 * r + 1e-07:
			s.append(j)
	max = r
	for j in s:
		if (4 * r * r - (x[i] - x[j]) ** 2) ** 0.5 + y[j] > max:
			max = (4 * r * r - (x[i] - x[j]) ** 2) ** 0.5 + y[j]
	y.append(max)
for i in y:
	print(i, end=' ')


(n, r) = list(map(int, input().split()))
p = 1
points = list(map(int, input().split()))
(x, y) = ([0 for i in range(n)], [0 for i in range(n)])
for i in range(n):
	x[i] = points[i]
	y[i] = r
	for j in range(i):
		if abs(x[j] - x[i]) <= 2 * r:
			ans = 4 * r ** 2
			d = abs(x[j] - x[i])
			d = d ** 2
			ans = ans - d
			ans = ans ** 0.5
			y[i] = max(y[i], y[j] + ans)
print(*y)


import math

def __starting_point():
	(n, r) = [int(x) for x in input().split()]
	x = [int(x) for x in input().split()]
	h = [None] * n
	for i in range(n):
		h[i] = r
		for j in range(i):
			if abs(x[i] - x[j]) <= 2 * r:
				h[i] = max(h[i], h[j] + math.sqrt(math.pow(2 * r, 2) - math.pow(x[i] - x[j], 2)))
	print(*h)
__starting_point()


import sys
input = sys.stdin.readline
(n, r) = map(int, input().split())
xs = list(map(int, input().split()))
points = []
for x in xs:
	y = r
	for (x0, y0) in points:
		if abs(x - x0) <= 2 * r:
			y = max(y, y0 + ((2 * r) ** 2 - (x - x0) ** 2) ** 0.5)
	points.append((x, y))
print(' '.join(('%.20f' % p[1] for p in points)))


ans = []
import math
disks_rad = [int(x) for x in input().split(' ')]
nums = [int(x) for x in input().split(' ')]
r = disks_rad[1]
ans.append(r)
for i in range(1, disks_rad[0]):
	y_cord = r
	for j in range(i):
		if (nums[i] - nums[j]) ** 2 <= r ** 2 * 4:
			y_cord = max(y_cord, ans[j] + math.sqrt(4 * r ** 2 - (nums[j] - nums[i]) ** 2))
	ans.append(y_cord)
print(' '.join([str(x) for x in ans]))


from math import sqrt
(n, r) = map(int, input().split())
x = list(map(int, input().split()))
disks = list()
for d in x:
	(X, Y) = (d, r)
	for disk in disks:
		dx = abs(disk[0] - d)
		if dx <= 2 * r:
			dy = sqrt(4 * r ** 2 - dx ** 2)
			y = disk[1] + dy
			if y > Y:
				Y = y
	disks.append((X, Y))
print(' '.join(map(str, [disk[1] for disk in disks])))


(n, r) = map(int, input().split())
a = list(map(int, input().split()))
st = []
for i in a:
	(left, right, cen) = (i - r, i + r, -1)
	for j in st:
		if not (j[0] > right or j[1] < left) and cen < ((2 * r) ** 2 - ((j[0] + j[1]) / 2 - i) ** 2) ** 0.5 + j[2]:
			cen = ((2 * r) ** 2 - ((j[0] + j[1]) / 2 - i) ** 2) ** 0.5 + j[2]
			k = j
	if cen == -1:
		st.append((left, right, r))
		c = r
	else:
		c = cen
		st.append((left, right, cen))
	print(c, end=' ')


from math import sqrt
(n, r) = list(map(int, input().split()))
x = list(map(int, input().split()))
o = []
for j in x:
	touch = []
	for p in o:
		if p[0] == j or p[0] + 2 * r == j or p[0] - 2 * r == j:
			touch.append(p)
		elif j > p[0] and j - r * 2 < p[0] or (j < p[0] and j + r * 2 > p[0]):
			touch.append(p)
	if touch == []:
		o.append([j, r])
	elif len(touch) == 1:
		i = max(touch, key=lambda x: x[1])
		if i[0] == j:
			o.append([j, i[1] + 2 * r])
		elif i[0] + 2 * r == j or i[0] - 2 * r == j:
			o.append([j, i[1]])
		else:
			o.append([j, i[1] + sqrt((r * 2) ** 2 - (max(i[0], j) - min(i[0], j)) ** 2)])
	elif len(touch) == 2:
		i = max(touch, key=lambda x: x[1])
		touch.remove(i)
		i2 = max(touch, key=lambda x: x[1])
		if i[1] + sqrt((r * 2) ** 2 - (max(i[0], j) - min(i[0], j)) ** 2) > i2[1] + sqrt((r * 2) ** 2 - (max(i2[0], j) - min(i2[0], j)) ** 2):
			o.append([j, i[1] + sqrt((r * 2) ** 2 - (max(i[0], j) - min(i[0], j)) ** 2)])
		elif i2[0] == j:
			o.append([j, i2[1] + 2 * r])
		elif i2[0] + 2 * r == j or i2[0] - 2 * r == j:
			o.append([j, i2[1]])
		else:
			o.append([j, i2[1] + sqrt((r * 2) ** 2 - (max(i2[0], j) - min(i2[0], j)) ** 2)])
	else:
		i = max(touch, key=lambda x: x[1])
		touch.remove(i)
		i2 = max(touch, key=lambda x: x[1])
		touch.remove(i2)
		i3 = max(touch, key=lambda x: x[1])
		if i3[1] + sqrt((r * 2) ** 2 - (max(i3[0], j) - min(i3[0], j)) ** 2) > i2[1] + sqrt((r * 2) ** 2 - (max(i2[0], j) - min(i2[0], j)) ** 2) and i3[1] + sqrt((r * 2) ** 2 - (max(i3[0], j) - min(i3[0], j)) ** 2) > i[1] + sqrt((r * 2) ** 2 - (max(i[0], j) - min(i[0], j)) ** 2):
			o.append([j, i3[1] + sqrt((r * 2) ** 2 - (max(i3[0], j) - min(i3[0], j)) ** 2)])
		elif i[1] + sqrt((r * 2) ** 2 - (max(i[0], j) - min(i[0], j)) ** 2) > i2[1] + sqrt((r * 2) ** 2 - (max(i2[0], j) - min(i2[0], j)) ** 2):
			o.append([j, i[1] + sqrt((r * 2) ** 2 - (max(i[0], j) - min(i[0], j)) ** 2)])
		elif i2[0] == j:
			o.append([j, i2[1] + 2 * r])
		elif i2[0] + 2 * r == j or i2[0] - 2 * r == j:
			o.append([j, i2[1]])
		else:
			o.append([j, i2[1] + sqrt((r * 2) ** 2 - (max(i2[0], j) - min(i2[0], j)) ** 2)])
print(' '.join([str(l[1]) for l in o]))


ip = lambda : map(int, input().split())
ipl = lambda : list(map(int, input().split()))
(n, r) = ip()
a = ipl()
l = []
for i in range(n):
	b = [r]
	for j in range(i):
		d = abs(a[i] - a[j])
		if d <= 2 * r:
			b.append((4 * r * r - d * d) ** 0.5 + l[j])
	l.append(max(b))
	print(max(b), end=' ')


(n, r) = map(int, input().split())
a = list(map(int, input().split()))
y = []
for i in a:
	ini = r
	for (x, j) in y:
		if abs(x - i) <= 2 * r:
			ini = max(ini, (4 * r * r - (x - i) ** 2) ** 0.5 + j)
	y.append([i, ini])
	print(ini, end=' ')


def list_output(s):
	print(' '.join(map(str, s)))

def list_input(s='int'):
	if s == 'int':
		return list(map(int, input().split()))
	elif s == 'float':
		return list(map(float, input().split()))
	return list(map(str, input().split()))
(n, r) = map(int, input().split())
xs = list(map(int, input().split()))
import math
ys = list()
for i in range(n):
	hit = False
	ymax = r
	for j in range(i):
		if 2 * r >= abs(xs[i] - xs[j]):
			hit = True
			ynew = ys[j] + math.sqrt(4.0 * r ** 2 - (xs[i] - xs[j]) ** 2)
			ymax = max(ymax, ynew)
	ys.append(ymax)
print(' '.join(map(str, ys)))


import math
(n, r) = map(int, input().split())
x = list(map(int, input().split()))
y = []
for i in range(n):
	y.append(max([r] + [math.sqrt(4 * r * r - (x[i] - x[j]) * (x[i] - x[j])) + y[j] for j in range(i) if abs(x[i] - x[j]) <= 2 * r]))
print(*y, sep=' ')


import sys
input = sys.stdin.readline

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

def lcm(a, b):
	return a * b / gcd(a, b)

def main():
	(n, r) = map(int, input().split())
	a = list(map(int, input().split()))
	ans = []
	ans.append(r)
	for i in range(1, n):
		ymax = r
		for j in range(i):
			if abs(a[j] - a[i]) <= 2 * r:
				ymax = max(ymax, ans[j] + (4 * r * r - (a[i] - a[j]) ** 2) ** 0.5)
		ans.append(ymax)
	print(*ans)
	return
main()


(n, r) = map(int, input().split())
data = list(map(int, input().split()))
save = []
for i in range(n):
	ans = r
	for j in save:
		d = abs(data[i] - j[0])
		if d <= 2 * r:
			ans = max(ans, j[1] + (4 * r ** 2 - d ** 2) ** 0.5)
	save.append([data[i], ans])
	print(ans, end=' ')


import math

def collide(x1, r1, x2, r2, y2):
	y = r1
	D = (r1 + r2) ** 2 - (x1 - x2) ** 2
	if D >= 0:
		y = max(y, math.sqrt(D) + y2)
	return y
(n, r) = [int(x) for x in input().split()]
X = [int(x) for x in input().split()]
Y = []
for i in range(n):
	y = r
	for j in range(i):
		y = max(y, collide(X[i], r, X[j], r, Y[j]))
	Y.append(y)
print(*Y)


(n, r) = map(int, input().split())
a = list(map(int, input().split()))
ans = [r]
for i in range(1, n):
	maxx = -1
	for j in range(i):
		if abs(a[i] - a[j]) <= 2 * r:
			c = ans[j] + (4 * r * r - (a[i] - a[j]) ** 2) ** 0.5
		else:
			c = r
		maxx = max(maxx, c)
	ans.append(maxx)
print(*ans)


(n, m) = [float(i) for i in input().split()]
l = [float(i) for i in input().split()]
al = []
for i in range(len(l)):
	ans = m
	for j in range(i):
		if abs(l[i] - l[j]) <= 2 * m:
			ans = max(ans, al[j] + (4 * m * m - (l[i] - l[j]) ** 2) ** 0.5)
	al.append(ans)
for i in al:
	print(i, end=' ')


(n, r) = list(map(int, input().split()))
X = [int(x) for x in input().split()]
Y = []
for i in range(n):
	forcedy = r
	for j in range(len(Y)):
		dist = abs(X[i] - X[j])
		if dist <= 2 * r:
			y = Y[j] + ((2 * r) ** 2 - dist ** 2) ** 0.5
			forcedy = max(y, forcedy)
	Y.append(forcedy)
print(*Y)


import math
(n, r) = map(int, input().split())
ans = [0.0] * n
a = list(map(float, input().split()))
for i in range(n):
	maxx = r
	for j in range(i):
		if abs(a[i] - a[j]) > 2 * r:
			continue
		maxx = max(maxx, ans[j] + math.sqrt(4 * r * r - (a[i] - a[j]) * (a[i] - a[j])))
	ans[i] = maxx
for i in range(n):
	print(ans[i], end=' ')


import math

def get_n():
	return int(input())

def get_int_vector():
	return [int(x) for x in input().split()]

def list2string(list):
	result = []
	for i in list:
		result.append(str(i))
	return ':'.join(result)

def string2vector(string):
	return [int(x) for x in string.split(':')]
(n, r) = get_int_vector()
final = []
for x in get_int_vector():
	center = [x, None]
	for pair in final:
		if x - r >= pair[0] - r and x - r <= pair[0] + r or (x + r >= pair[0] - r and x + r <= pair[0] + r):
			y = pair[1] + math.sqrt(4 * r ** 2 - (x - pair[0]) ** 2)
			if center[1] == None or center[1] < y:
				center[1] = y
	if center[1] == None:
		center[1] = r
	print('{:.7f}'.format(center[1]))
	final.append(center)


(n, r) = map(int, input().split())
l = list(map(int, input().split()))
ans = [r] * n
for i in range(n):
	for j in range(i):
		if 4 * r ** 2 - (max(l[i], l[j]) - min(l[i], l[j])) ** 2 >= 0:
			y = 4 * r ** 2 - (max(l[i], l[j]) - min(l[i], l[j])) ** 2
			ans[i] = max(ans[i], ans[j] + y ** 0.5)
print(*ans)


import math
(n, r) = map(int, input().split())
a = list(map(int, input().split()))
a.append(0)
b = [0 for i in range(n)]
b[0] = a[0]
for i in range(1, n + 1):
	w = r
	for j in range(1, i):
		dx = abs(a[j - 1] - a[i - 1])
		if dx > 2 * r:
			continue
		w = max(w, b[j - 1] + math.sqrt(4 * r * r - dx * dx))
	b[i - 1] = w
print(*b)


(n, r) = map(int, input().split())
l = list(map(int, input().split()))
ds = []
for i in range(len(l)):
	ans = [l[i], r]
	x = l[i]
	for j in range(len(ds)):
		if abs(x - ds[j][0]) <= 2 * r:
			ans[1] = max(ans[1], ds[j][1] + (4 * r * r - (x - ds[j][0]) ** 2) ** 0.5)
	ds.append(ans)
ls = []
for j in range(n):
	ls.append(ds[j][1])
print(*ls)


a = list(map(int, input().split(' ')))
y = list(map(int, input().split(' ')))
circ = []
for i in range(a[0]):
	fy = a[1]
	for j in circ:
		delta = abs(y[i] - j[0])
		if delta <= 2 * a[1]:
			fy = max(fy, j[1] + ((2 * a[1]) ** 2 - delta ** 2) ** 0.5)
	circ.append([y[i], fy])
for i in circ:
	print(i[1], end=' ')


(n, r) = map(int, input().split())
A = list(map(int, input().split()))
B = []
B.append([r, A[0] - r, A[0] + r])
print(r, end=' ')
for i in range(1, n):
	B = sorted(B, key=lambda l: l[0], reverse=True)
	m = 0
	k = 0
	for j in B:
		if j[1] - r <= A[i] <= j[2] + r:
			k = j[0] + (4 * r * r - abs(A[i] - j[1] - r) ** 2) ** 0.5
			if k > m:
				m = k
	if m == 0:
		B.append([r, A[i] - r, A[i] + r])
		print(round(r, 11), end=' ')
	else:
		B.append([round(m, 11), A[i] - r, A[i] + r])
		if m % 1 == 0:
			print(int(m), end=' ')
		else:
			print(round(m, 11), end=' ')


(n, r) = map(int, input().split())
a = list(map(int, input().split()))
listy = []
for i in range(n):
	b = [r]
	for j in range(i):
		d = abs(a[i] - a[j])
		if d <= 2 * r:
			b.append((4 * r * r - d * d) ** 0.5 + listy[j])
	listy.append(max(b))
	print(max(b), end=' ')


(n, r) = map(int, input().split())
x = [int(i) for i in input().split()]
c = []
for i in range(n):
	k = r
	for (x1, j) in c:
		d = abs(x[i] - x1)
		if d <= 2 * r:
			k = max(k, j + (4 * r ** 2 - d * d) ** 0.5)
	c.append([x[i], k])
	print(k)


(n, r) = map(int, input().split())
x = list(map(int, input().split()))
y = [r] * n
for i in range(n):
	for j in range(i):
		if not abs(x[i] - x[j]) > 2 * r:
			y[i] = max(y[i], (4 * r ** 2 - (x[i] - x[j]) ** 2) ** 0.5 + y[j])
for i in y:
	print(i, end=' ')


from math import sqrt
(n, r) = map(int, input().split())
x_list = list(map(int, input().split()))
y_list = []
for i in range(n):
	y_val = r
	for j in range(i):
		if abs(x_list[i] - x_list[j]) <= 2 * r:
			y_curr = sqrt(4 * r * r - (x_list[i] - x_list[j]) * (x_list[i] - x_list[j])) + y_list[j]
			y_val = max(y_val, y_curr)
	y_list.append(y_val)
print(' '.join(map(str, y_list)))


(n, r) = list(map(int, input().split()))
x = list(map(int, input().split()))
r2r4 = 4 * r ** 2
y = []
for i in range(0, n):
	max_y = r
	for j in range(i):
		if r2r4 >= (x[i] - x[j]) ** 2:
			max_y = max(max_y, y[j] + (r2r4 - (x[i] - x[j]) ** 2) ** 0.5)
	y.append(max_y)
print(*y)


(n, r) = [int(i) for i in input().split(' ')]
x = [int(i) for i in input().split(' ')]
y = []
for i in range(n):
	contact = -1
	cury = r
	for j in range(i):
		if x[i] - r <= x[j] + r and x[i] + r >= x[j] - r:
			if contact == -1:
				contact = j
				cury = y[j] + (4 * r ** 2 - (x[i] - x[j]) ** 2) ** 0.5
			else:
				tempy = y[j] + (4 * r ** 2 - (x[i] - x[j]) ** 2) ** 0.5
				if tempy > cury:
					contact = j
					cury = tempy
	y.append(cury)
for i in range(n - 1):
	print(y[i], end=' ')
print(y[n - 1])


from math import sqrt
s = str(input())
(n, r) = (int(s.split(' ')[0]), float(s.split(' ')[1]))
xs = str(input()).split(' ')
xs = [int(x) for x in xs]
locations = []
for x in xs:
	y = r
	for loc in locations:
		(x2, y2) = loc
		if abs(x2 - x) <= 2 * r:
			y = max(y, y2 + sqrt(4 * r * r - abs(x2 - x) * abs(x2 - x)))
	locations.append((x, y))
for l in locations:
	print(str(l[1]), end=' ')


from math import sqrt
first_line = input().split(' ')
second_line = input().split(' ')
RADIO = float(first_line[1])
X_POSITIONS = [float(x) for x in second_line]

def stop_point(x0, y0, x_i):
	delta = 4 * RADIO ** 2 - (x_i - x0) ** 2
	if delta >= 0:
		y_i = y0 + sqrt(delta)
	else:
		y_i = RADIO
	return y_i
disks = []
for x in X_POSITIONS:
	max_y = RADIO
	for c in disks:
		y = stop_point(c[0], c[1], x)
		max_y = y if y > max_y else max_y
	disk = (x, max_y)
	disks.append(disk)
print(' '.join([str(y) for (x, y) in disks]))


from math import sqrt
(n, r) = map(int, input().split())
a = list(map(int, input().split()))
result = [0] * n
result[0] = r
coord = {i: [0, 0] for i in range(n)}
coord[0] = [a[0], result[0]]
for i in range(1, n):
	f = True
	for j in range(i - 1, -1, -1):
		if abs(a[j] - a[i]) <= 2 * r:
			A = sqrt((2 * r - a[i] + a[j]) * (2 * r + a[i] - a[j]))
			ans = coord[j][1] + A
			if ans > result[i]:
				coord[i][0] = a[i]
				result[i] = ans
				coord[i][1] = result[i]
			f = False
	if f:
		result[i] = r
		coord[i] = [a[i], result[i]]
print(*result)


from math import sqrt
(n, r) = map(int, input().split(' '))
x = list(map(int, input().split(' ')))
center = [(r, x[0])]
center_ans = str(r)
for i in range(1, n):
	center_tmp = []
	for j in range(i):
		dif_x = abs(center[j][1] - x[i])
		if dif_x > 2 * r:
			center_tmp.append((r, x[i]))
			continue
		else:
			dif_y = float(sqrt(4 * r ** 2 - dif_x ** 2))
			y = float(center[j][0]) + dif_y
			center_tmp.append((y, x[i]))
	center.append(max(center_tmp))
	center_ans += ' ' + str(center[i][0])
print(center_ans)


(n, r) = map(int, input().split())
discs = {}
s = list(map(int, input().split()))
discs[s[0]] = r
print(r, end=' ')
b = lambda y: (4 * r ** 2 - y ** 2) ** 0.5
for i in range(1, n):
	xi = s[i]
	found = False
	to_app = []
	for x in discs:
		res = b(x - xi)
		if type(res) != complex:
			to_app.append(res + discs[x])
			found = True
	if found:
		prin = max(to_app)
		discs[xi] = prin
		print(prin, end=' ')
	else:
		discs[xi] = r
		print(r, end=' ')


import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
import collections
from itertools import permutations
import threading
from collections import defaultdict
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
read = lambda : map(int, input().split())
(n, r) = read()
x = list(read())
y = [0] * n
for i in range(n):
	cur = r
	for j in range(i):
		if 2 * r >= abs(x[i] - x[j]):
			cur = max(cur, y[j] + (4 * r * r - (x[i] - x[j]) ** 2) ** 0.5)
	y[i] = cur
print(*y)


from sys import stdin
from math import sqrt

def valid_discriminant(a, b, c):
	d = b * b - 4 * a * c
	if d < 0:
		return (False, -1)
	else:
		return (True, d)

def get_y2(a, b, d):
	b = -1 * b
	y1 = (b + sqrt(d)) / (2 * a)
	y2 = (b - sqrt(d)) / (2 * a)
	return max(y1, y2)
(n, r) = stdin.readline().split()
n = int(n)
r = int(r)
dist = r + r
inputs = stdin.readline().split()
xinput = [int(item) for item in inputs[1:]]
listcord = []
cord = {}
cord['y'] = r
cord['x'] = int(inputs[0])
listcord.append(cord)
for (index, x2) in enumerate(xinput):
	y2 = r
	for _cord in listcord:
		x1 = _cord['x']
		y1 = _cord['y']
		a = 1
		b = -2 * y1
		xdiff = x2 - x1
		c = y1 * y1 - dist * dist + xdiff * xdiff
		(flag, d) = valid_discriminant(a, b, c)
		if flag:
			temp_y2 = get_y2(a, b, d)
		else:
			temp_y2 = r
			continue
		if y2 < temp_y2:
			y2 = temp_y2
	cord = {}
	cord['y'] = y2
	cord['x'] = x2
	listcord.append(cord)
y = ' '.join([str(item['y']) for item in listcord])
print(y)


import math
(n, r) = tuple(map(int, input().split()))
circles = list(map(int, input().split()))
output = []
for x in circles:
	init = r
	for (xt, y) in output:
		if abs(xt - x) <= 2 * r:
			init = max(init, (4 * r * r - (x - xt) ** 2) ** 0.5 + y)
	print(init, end=' ')
	output.append([x, init])


R = lambda : map(int, input().split())
(n, r) = R()
xs = list(R())
ys = []
for i in range(n):
	ys.append(max([((2 * r) ** 2 - abs(xs[i] - xs[j]) ** 2) ** 0.5 + ys[j] for j in range(i) if abs(xs[i] - xs[j]) <= 2 * r], default=r))
print(*ys)


(n, m) = map(int, input().split())
c = list(map(int, input().split()))
a = [m]
for i in range(1, n):
	l = 0
	for j in range(i):
		if abs(c[i] - c[j]) <= 2 * m:
			l = max(l, (4 * m * m - (c[i] - c[j]) ** 2) ** 0.5 + a[j])
	l = max(l, m)
	a.append(l)
print(*a)


(n, r) = list(map(int, input().strip().split()))
x = list(map(int, input().strip().split()))
fallen = [[x[0], r]]
for i in range(1, len(x)):
	k = len(fallen) - 1
	maks = r
	for k in range(len(fallen)):
		(xi, yi) = fallen[k]
		if abs(x[i] - xi) <= 2 * r + 10 ** (-10):
			y1 = ((2 * r) ** 2 - (xi - x[i]) ** 2) ** 0.5
			maks = max(maks, yi + y1)
	fallen.append((x[i], maks))
cent = [e for (a, e) in fallen]
print(' '.join(map(str, cent)))


import math
import sys
(n, r) = list(map(int, input().split(' ')))
x = list(map(int, input().split(' ')))
y = list()
for i in range(0, n):
	y.append(r)
	for j in range(0, i):
		if 2 * r == abs(x[i] - x[j]):
			y[i] = max(y[i], y[j])
		elif 2 * r > abs(x[i] - x[j]):
			y[i] = max(y[i], y[j] + math.sqrt(2 * r * 2 * r - abs(x[i] - x[j]) * abs(x[i] - x[j])))
for i in range(0, n):
	sys.stdout.write(str(y[i]) + ' ')


from math import *
(n, r) = map(int, input().split())
x = list(map(int, input().split()))
ans = []
for i in range(n):
	yi = r
	for j in range(i):
		if abs(x[j] - x[i]) <= 2 * r:
			yi = max(yi, ans[j] + sqrt(4 * r ** 2 - (x[j] - x[i]) ** 2))
	ans.append(yi)
print(' '.join(map(str, ans)))


(n, r) = map(int, input().split())
x_data = list(map(int, input().split()))
y_data = []
for i in range(n):
	y = r
	for j in range(i):
		if abs(x_data[j] - x_data[i]) <= 2 * r:
			y = max(y, (4 * r * r - (x_data[i] - x_data[j]) ** 2) ** 0.5 + y_data[j])
	y_data.append(y)
print(*y_data)


import os
import sys
from math import *
from collections import *
from bisect import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
ALPHA = 'abcdefghijklmnopqrstuvwxyz'
M = 10 ** 9 + 7
EPS = 1e-06

def Ceil(a, b):
	return a // b + int(a % b > 0)

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]

def intersect(x1, x2):
	d = abs(x1 - x)
	return d <= 2 * r
(n, r) = value()
have = []
a = array()
for x in a:
	y = r
	for (x1, h) in have:
		if intersect(x, x1):
			R = 4 * r * r
			d = abs(x - x1) ** 2
			try:
				y = max(y, h + sqrt(R - d))
			except:
				pass
	have.append((x, y))
for (x, y) in have:
	print(y, end=' ')


from math import sqrt
(n, r) = map(int, input().split())
a = list(map(int, input().split()))
y = [[a[0], r]]
for i in range(1, n):
	k = r
	for j in range(len(y)):
		if abs(a[i] - y[j][0]) <= 2 * r:
			k = max(k, sqrt(4 * r * r - (a[i] - y[j][0]) ** 2) + y[j][1])
	y.append([a[i], k])
print(*[y[i][1] for i in range(len(y))], sep=' ')


import math
(n, r) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
b = []

def inter1(x1, x2, b):
	(x3, x4, y) = b
	if x1 < x3:
		if x2 >= x3:
			return True
		else:
			return False
	elif x4 >= x1:
		return True
	else:
		return False
ans = []

def inter2(b, xl, xr, r):
	x1 = xl + r
	x2 = b[0] + r
	y = b[2]
	dy = math.sqrt(4 * r * r - abs(x1 - x2) * abs(x1 - x2))
	return y + dy
for i in range(len(a)):
	xl = a[i] - r
	xr = a[i] + r
	maxy = 0
	zn = 0
	for z in range(len(b)):
		if inter1(xl, xr, b[z]):
			maxy = b[z][2]
			ny = inter2(b[z], xl, xr, r)
			zn = max(zn, ny)
	if zn != 0:
		b.append((xl, xr, zn))
		ans.append(zn)
	if maxy == 0:
		b.append((xl, xr, r))
		ans.append(r)
print(*ans)


l = list(map(int, input().rstrip().split()))
n = l[0]
r = l[1]
num = list(map(int, input().rstrip().split()))
final = []
mahalist = []
for i in range(len(num)):
	mahalist = []
	if i == 0:
		final.append(r)
		mahalist.append(r)
	else:
		for j in range(i):
			if abs(num[i] - num[j]) <= 2 * r:
				mahalist.append(((2 * r) ** 2 - (num[i] - num[j]) ** 2) ** 0.5 + final[j])
			else:
				mahalist.append(r)
		final.append(max(mahalist))
for i in final:
	print(i, end=' ')


(n, r) = map(int, input().split())
y = []
x = list(map(int, input().split()))
for xi in x:
	yi = r
	for (tx, ty) in zip(x, y):
		if xi - 2 * r <= tx <= xi + 2 * r:
			dy = (4.0 * r ** 2 - (tx - xi) ** 2) ** 0.5
			yi = max(yi, ty + dy)
	y.append(yi)
print(*y)


(n, r) = list(map(int, input().split()))
disks = list(map(int, input().split()))
atline = [[disks[0], r]]
for i in range(1, n):
	sup = r
	thisd = disks[i]
	for disk in atline:
		dx = disk[0] - thisd
		if abs(dx) > 2 * r:
			continue
		y = disk[1] + (4 * r * r - dx * dx) ** 0.5
		sup = max(sup, y)
	atline += [[thisd, sup]]
s = ''
for d in atline:
	s += str(d[1]) + ' '
print(s)


from math import sqrt

def main():
	(n, r) = map(int, input().split())
	coords = [(int(i), 1000000000.0) for i in input().split()]
	for (i, val) in enumerate(coords):
		(x, y) = val
		if not i:
			coords[i] = (x, r)
			continue
		candidates = coords[:i]
		ymax = -1
		for (xx, yy) in candidates:
			if 4 * r ** 2 - (x - xx) ** 2 < 0:
				continue
			y1 = sqrt(4 * r ** 2 - (x - xx) ** 2) + yy
			y2 = yy - sqrt(4 * r ** 2 - (x - xx) ** 2)
			if y1 > ymax and r <= y1 <= y:
				ymax = y1
			if y2 > ymax and r <= y2 <= y:
				ymax = y2
		if ymax == -1:
			ymax = r
		coords[i] = (x, ymax)
	for (xx, yy) in coords:
		print(yy, end=' ')
main()


from math import sqrt
(n, r) = map(int, input().split())
circles = {}
totCircles = []
xs = [x for x in map(int, input().split())]
for x in xs:
	intersects = []
	for i in range(x - 2 * r, x + 2 * r + 1):
		if i in circles:
			d = abs(x - i) / 2
			h = circles[i] + 2 * sqrt(r ** 2 - d ** 2)
			intersects.append((i, h))
	if not intersects:
		circles[x] = r
		totCircles.append(r)
		continue
	maxIntersect = sorted(intersects, key=lambda x: x[1])[-1]
	dist = abs(x - maxIntersect[0]) / 2
	y = maxIntersect[1]
	circles[x] = y
	totCircles.append(y)
print(*totCircles)


import math
(n, r) = map(int, input().split())
a = list(map(int, input().split()))
ys = []
for i in range(n):
	ans = r
	for j in range(len(ys)):
		if abs(a[i] - a[j]) <= 2 * r:
			ans = max(ans, ys[j] + math.sqrt(4 * r * r - (a[i] - a[j]) * (a[i] - a[j])))
	ys.append(ans)
print(*ys)


R = lambda : map(int, input().split())
R1 = lambda : map(float, input().split())
(n, r) = R()
a = list(R1())
pos = []
t = 4.0 * r * r
for i in range(n):
	cons = [r]
	for k in range(i):
		t1 = t - (a[k] - a[i]) ** 2
		if t1 >= 0:
			t2 = t1 ** (1 / 2)
			cons.append(pos[k] + t2)
	pos.append(max(cons))
print(*pos, sep=' ')


(n, r) = map(int, input().split())
(x, y) = (list(map(int, input().split())), [r] * n)

def f(xi, xj, yj):
	d = abs(xi - xj)
	return r if d > 2 * r else yj + (4 * r ** 2 - d ** 2) ** 0.5
for i in range(1, n):
	y[i] = max((f(x[i], x[j], y[j]) for j in range(i)))
print(' '.join(map(str, y)))


(n, r) = map(int, input().split())
a = [*map(int, input().split())]
ans = [r] * n
for i in range(n):
	for j in range(i):
		if abs(a[j] - a[i]) <= 2 * r:
			ans[i] = max(ans[i], (4 * r * r - (a[j] - a[i]) ** 2) ** 0.5 + ans[j])
	print(ans[i], end=' ')
print()


maxN = int(100000.0 + 3)
eps = 1e-10
x = [0 for k in range(maxN)]
y = [0 for k in range(maxN)]
n = 0
r = 0
d = 0

def read():
	global x, n, r, d
	(n, r) = (int(k) for k in input().split())
	r = float(r)
	d = 2 * r
	x = [float(k) for k in input().split()]

def doit():
	for i in range(n):
		this_y = r
		for j in range(i):
			dx = abs(x[i] - x[j])
			if dx < d + eps:
				new_y = y[j] + (d ** 2 - dx ** 2) ** 0.5
				if new_y > this_y:
					this_y = new_y
		y[i] = this_y

def main():
	read()
	doit()
	print(*y[:n])
main()


from math import sqrt
(n, r) = [int(x) for x in input().split()]
xcoords = [int(x) for x in input().split()]
ycoords = [-1 for x in xcoords]
for (i, disk) in enumerate(xcoords):
	maxy = r
	for (j, disk2) in enumerate(xcoords):
		if disk2 < disk - 2 * r or disk2 > disk + 2 * r or ycoords[j] == -1:
			continue
		y = sqrt(pow(2 * r, 2) - pow(abs(disk2 - disk), 2)) + ycoords[j]
		if y > maxy:
			maxy = y
	ycoords[i] = maxy
s = ''
for disk in ycoords:
	s += str(disk) + ' '
print(s[:-1])


from math import sqrt
(N, R) = map(int, input().split())
disk_xs = map(int, input().split())
disks = []
for x in disk_xs:
	y = R
	for (x0, y0) in disks:
		sq = 4 * R ** 2 - (x0 - x) ** 2
		if sq >= 0:
			y1 = y0 + sqrt(sq)
			y = max(y, y1)
	disks.append((x, y))
print(' '.join(map(lambda x: str(x[1]), disks)))


(n, r) = map(int, input().split())
rad = list(map(int, input().split()))
y = []
for i in range(n):
	y.append(r)
	for j in range(i):
		d = abs(rad[i] - rad[j])
		if d > 2 * r:
			continue
		inc = (4 * r ** 2 - d ** 2) ** (1 / 2)
		y[i] = max(y[i], y[j] + inc)
print(' '.join(map(str, y)))


import math
(n, r) = map(int, input().split())
x = input().split()
y = []
for i in range(n):
	x[i] = int(x[i])
	y.append(-1)
for i in range(n):
	y[i] = r
	for j in range(i):
		if math.fabs(x[j] - x[i]) <= 2 * r:
			y0 = y[j]
			x0 = x[j]
			y[i] = max(y0 + math.sqrt(4 * r * r - (x[i] - x0) * (x[i] - x0)), y[i])
for i in range(n):
	print(y[i], end=' ')


import math as mt
import sys, string, bisect
input = sys.stdin.readline
from collections import deque, defaultdict
from decimal import *
getcontext().prec = 100
L = lambda : list(map(int, input().split()))
Ls = lambda : list(input().split())
M = lambda : map(int, input().split())
I = lambda : int(input())

def dist(x, y, c, d):
	return (x - c) ** 2 + (y - d) ** 2

def circle(x1, y1, x2, y2, r1, r2):
	distSq = ((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)) ** 0.5
	if distSq + r2 <= r1:
		return True
	else:
		return False
(n, r) = M()
l = L()
c = [(l[0], r, 0)]
for i in range(1, n):
	x = len(c)
	k = 0
	f = 0
	while k < x:
		a = c[k][0]
		b = c[k][1]
		g = l[i]
		if 4 * r ** 2 >= (g - a) ** 2:
			re = mt.sqrt(4 * r ** 2 - (g - a) ** 2) + b
			f = max(f, re)
		k += 1
	c.append((g, max(f, r), i))
c.sort(key=lambda x: x[2])
for i in range(n):
	print(c[i][1], end=' ')


import math
(n, r) = list(map(int, input().split()))
a = list(map(int, input().split()))
new = [r for i in range(n)]
for i in range(1, n):
	for j in range(i):
		temp = (2 * r) ** 2 - (a[i] - a[j]) ** 2
		if temp >= 0:
			new[i] = max(new[i], math.sqrt(temp) + new[j])
print(*new)


(n, r) = map(int, input().split())
x = list(map(float, input().split()))
ptns = []
for i in range(n):
	ty = r
	for (x1, y1) in ptns:
		rast = abs(x1 - x[i])
		if rast <= 2 * r:
			ny = y1 + (4 * r * r - rast * rast) ** 0.5
			if ny > ty:
				ty = ny
	ptns.append([x[i], ty])
	print(ty)


import math

def touch_y(x1, y1, x2):
	if abs(x1 - x2) > 2 * r:
		return r
	x_touch_offset = abs(x1 - x2) / 2.0
	y_touch = y1 + 2 * math.sqrt(r * r - x_touch_offset * x_touch_offset)
	return y_touch

def solve(xi, r):
	solution = []
	for x in xi:
		if len(solution) == 0:
			solution = [r]
		else:
			max_y = 0
			for i in range(len(solution)):
				max_y = max(max_y, touch_y(xi[i], solution[i], x))
			solution.append(max_y)
	print(' '.join([str(s) for s in solution]))
n_and_r = input()
r = float(n_and_r.split(' ')[1])
xi = [float(n) for n in input().split(' ')]
solve(xi, r)


from math import *
(n, m) = input().split()
n = int(n)
m = int(m)
xcenters = [int(i) for i in input().split()]
result = []
for i in range(0, n):
	badones = []
	for j in range(0, i):
		if abs(xcenters[j] - xcenters[i]) <= 2 * m:
			badones.append(j)
	if len(badones) == 0:
		result.append(m)
		continue
	maxheight = m
	for x in badones:
		temp = result[x] + sqrt(4 * m * m - (xcenters[x] - xcenters[i]) ** 2)
		if maxheight < temp:
			maxheight = temp
	result.append(maxheight)
print(*result)


(n, r) = [int(i) for i in input().split()]
inp = [int(i) for i in input().split()]
disks = []
import math
for i in inp:
	mxY = r
	for j in disks:
		if 2 * r >= abs(j[0] - i):
			y = j[1] + math.sqrt(4 * r * r - (j[0] - i) * (j[0] - i))
			mxY = max(mxY, y)
	disks.append([i, mxY])
for i in disks:
	print(i[1], end=' ')


import math
(n, r) = list(map(int, input().split()))
x = list(map(int, input().split()))
y = [r for i in range(n)]
for i in range(n):
	y[i] = max([r] + [y[j] + math.sqrt(4 * r ** 2 - (x[i] - x[j]) ** 2) for j in range(i) if abs(x[i] - x[j]) <= 2 * r])
	print('{:.10f}'.format(y[i]), end=' ')


import math

class Point:

	def __init__(self, x, y):
		self.x = x
		self.y = y

class Curling:

	def __init__(self, r):
		self.r = r
		self.r2 = r * r
		self.d = r * 2
		self.disks = []
		self.results = []

	def add(self, x):
		min_y = [self.r]
		for disk in self.disks:
			x_distance = abs(x - disk.x)
			if x_distance == 0:
				min_y.append(disk.y + self.d)
			elif x_distance == self.d:
				min_y.append(disk.y)
			elif x_distance < self.d:
				min_y.append(self.calc_min_y(disk, x))
		disk = Point(x, max(min_y))
		self.disks.append(disk)
		self.results.append(str(disk.y))

	def calc_min_y(self, disk: Point, x):
		cx = abs(disk.x - x) / 2
		dy = math.sqrt(self.r2 - cx * cx)
		return disk.y + 2 * dy
[n, r] = list(map(int, input().split()))
curling = Curling(r)
x_positions = list(map(int, input().split()))
for x_position in x_positions:
	curling.add(x_position)
print(' '.join(curling.results))


import math
from collections import namedtuple
Disk = namedtuple('Disk', ['x', 'y'])
(n, r) = tuple(map(int, input().split()))
disks = list(map(int, input().split()))
active = []
for x in disks:
	possible_y = [r]
	for a in active:
		if abs(a.x - x) <= 2 * r:
			dy = math.sqrt(4 * r ** 2 - abs(a.x - x) ** 2)
			possible_y.append(a.y + dy)
	active.append(Disk(x, max(possible_y)))
y_coords = [str(a.y) for a in active]
print(' '.join(y_coords))


import math

def gety(x, y, x1):
	return abs(y + math.sqrt(d ** 2 - (x - x1) ** 2))
(n, r) = map(int, input().split())
x = list(map(int, input().split()))
y = [r]
d = 2 * r
center = [[x[0], r]]
for i in range(1, n):
	c = []
	c_temp = list(reversed(center))
	for item in c_temp:
		if abs(item[0] - x[i]) <= d:
			c.append(item)
	temp = []
	for item in c:
		temp.append(gety(item[0], item[1], x[i]))
	y1 = max([r] + temp)
	center.append([x[i], y1])
	y.append(y1)
print(*y)


import math
EP = 1e-09
(N, R) = map(int, input().split())
X = list(map(int, input().split()))
pts = []
for x in X:
	y = R
	for pt in pts:
		dst = (2.0 * R) ** 2.0 - (pt[0] - x) ** 2.0
		if dst > -EP:
			y = max(y, pt[1] + math.sqrt(max(0.0, dst)))
	pts.append((x, y))
print(' '.join(('%.10f' % pt[1] for pt in pts)))


import math
(n, r) = list(map(int, input().split()))
x = list(map(int, input().split()))
y = [10 ** 100] * n
for i in range(n):
	d_y = 0
	for j in range(i):
		if 4 * r * r < (x[i] - x[j]) * (x[i] - x[j]):
			continue
		tmp_y = y[j] + math.sqrt(4 * r * r - (x[i] - x[j]) * (x[i] - x[j]))
		d_y = max(d_y, tmp_y)
	y[i] = max(r, d_y)
for i in range(n):
	print(y[i], end=' ')


(n, r) = map(int, input().split())
x = list(map(int, input().split()))
res = []
for i in range(len(x)):
	y = r
	for j in range(i):
		dx = abs(x[i] - x[j])
		if dx > 2 * r:
			continue
		Y = res[j] + (4 * r * r - dx ** 2) ** 0.5
		y = max([y, Y])
	res.append(float(y))
print(*res)


from math import *
(a, r) = map(int, input().split())
x = list(map(int, input().split()))
y = [0] * a
for i in range(a):
	h = r
	for j in range(i):
		if abs(x[i] - x[j]) <= 2 * r:
			h = max(h, sqrt((2 * r) ** 2 - (x[i] - x[j]) ** 2) + y[j])
	y[i] = h
	print(h, end=' ')


(num_disks, radius) = list(map(int, input().strip().split()))
x_locs = list(map(int, input().strip().split()))
locs = []
for x_loc in x_locs:
	max_y = radius
	for (x, y) in locs:
		base = (radius * 2) ** 2 - (x_loc - x) ** 2
		if base < 0:
			continue
		new_y = base ** 0.5 + y
		if new_y > max_y:
			max_y = new_y
	locs.append((x_loc, max_y))
	print(max_y)


import math
(n, r) = map(int, input().split())
disk_list = map(int, input().split())
t = [-1 * r for i in range(1001)]
result = []
for disk in disk_list:
	start = disk - r * 2
	if start < 0:
		start = 0
	end = disk + r * 2
	if end > 1000:
		end = 1000
	max_y = 0
	for i in range(start, end + 1):
		x1 = i
		y1 = t[i]
		x2 = disk
		y2 = math.sqrt(4 * r ** 2 - abs(x1 - x2) ** 2) + y1
		if y2 > max_y:
			max_y = y2
	t[disk] = max_y
	result.append(max_y)
for i in result:
	print(i, end=' ')


(n, r) = map(int, input().split())
xs = list(map(int, input().split()))
import math

def ch(c1, c2):
	d = abs(c1[0] - c2[0])
	ph = math.sqrt(2 * 2 * r * r - d * d)
	return c2[1] + ph
cs = []
for i in range(len(xs)):
	h = r
	x = xs[i]
	for c in cs:
		if abs(x - c[0]) > 2 * r:
			continue
		else:
			h = max(h, ch([x, h], c))
	cs.append([x, h])
print(' '.join([str(i[1]) for i in cs]))


import itertools
inf = float('inf')
read_ints = lambda : list(map(int, input().split()))

def intersects(x1, y1, x2, y2, r):
	return ((x1 - x2) ** 2 + (y1 - y2) ** 2) ** 0.5 <= 2 * r

def get_intersection_y(x, xt, yt, r):
	if abs(x - xt) > 2 * r:
		return r
	return yt + (4 * r ** 2 - (x - xt) ** 2) ** 0.5
(n, r) = read_ints()
r = float(r)
xs = list(map(float, input().split()))
ys = [r] * n
for i in range(1, n):
	ys[i] = max([get_intersection_y(xs[i], xt, yt, r) for (xt, yt) in zip(xs[:i], ys[:i])])
print(' '.join(map(str, ys)))


(n, r) = map(int, input().split())
a = [int(i) for i in input().split()]
s = []
arr = []
s.append(r)
arr.append(a[0])
for i in range(1, n):
	an = r
	f = False
	temp = -1
	for j in range(len(arr)):
		if arr[j] <= a[i] + 2 * r and arr[j] >= a[i] - 2 * r:
			an = max(an, s[j] + (pow(2 * r, 2) - pow(a[i] - arr[j], 2)) ** 0.5)
			f = True
	s.append(an)
	arr.append(a[i])
for j in range(len(s)):
	print(s[j], end=' ')


import math
(n, r) = input().split(' ')
n = int(n)
r = float(r)
pos = [[float(x) for x in input().split(' ')], [r] * n]
for i in range(n):
	maxy = pos[1][i]
	for j in range(i):
		mindist = math.fabs(pos[0][i] - pos[0][j])
		if mindist <= 2 * r:
			maxy = max(maxy, pos[1][j] + math.sqrt(4 * r * r - mindist * mindist))
	pos[1][i] = maxy
print(' '.join([str(y) for y in pos[1]]))


import time
(n, r) = (0, 0)
x = []
y = []

def calc_y(x, x1, y1):
	dx = abs(x - x1)
	if dx > 2 * r:
		return r
	dy = (4 * r ** 2 - dx ** 2) ** (1 / 2)
	return y1 + dy

def let_fall_disk(i):
	global n, r, x, y
	return max([calc_y(x[i], x[j], y[j]) for j in range(i)] + [r])

def let_fall_disks():
	global n, r, x, y
	for i in range(n):
		y += [let_fall_disk(i)]

def get_values():
	global n, r, x, y
	(n, r) = (int(a) for a in input().split())
	x = [int(a) for a in input().split()]

def main():
	get_values()
	if len(x) != n:
		return
	let_fall_disks()
	print(' '.join([str(e) for e in y]))
main()


I = lambda : input().split(' ')
a = I()
y = I()
c = []
for i in range(int(a[0])):
	f = int(a[1])
	g = 2 * f
	h = int(y[i])
	for j in c:
		d = abs(h - j[0])
		if d <= g:
			f = max(f, j[1] + (g * g - d * d) ** 0.5)
	c.append([h, f])
for i in c:
	print(i[1])


import bisect
from itertools import accumulate, count
import os
import sys
import math
from decimal import *
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def SieveOfEratosthenes(n):
	prime = []
	primes = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if primes[p] == True:
			prime.append(p)
			for i in range(p * p, n + 1, p):
				primes[i] = False
		p += 1
	primes[1] = False
	primes[0] = False
	return primes

def primefactors(n):
	fac = []
	while n % 2 == 0:
		fac.append(2)
		n = n // 2
	for i in range(3, int(math.sqrt(n)) + 2):
		while n % i == 0:
			fac.append(i)
			n = n // i
	if n > 1:
		fac.append(n)
	return fac

def factors(n):
	fac = set()
	fac.add(1)
	fac.add(n)
	for i in range(2, int(math.sqrt(n)) + 1):
		if n % i == 0:
			fac.add(i)
			fac.add(n // i)
	return list(fac)

def NcR(n, r):
	p = 1
	k = 1
	if n - r < r:
		r = n - r
	if r != 0:
		while r:
			p *= n
			k *= r
			m = math.gcd(p, k)
			p //= m
			k //= m
			n -= 1
			r -= 1
	else:
		p = 1
	return p

def Log2(x):
	if x == 0:
		return False
	return math.log10(x) / math.log10(2)

def isPowerOfTwo(n):
	return math.ceil(Log2(n)) == math.floor(Log2(n))
(n, r) = map(int, input().split())
x = [int(i) for i in input().split()]
c = []
for i in range(n):
	k = r
	for (x1, j) in c:
		d = abs(x[i] - x1)
		if d <= 2 * r:
			k = max(k, j + (4 * r ** 2 - d * d) ** 0.5)
	c.append([x[i], k])
	print(k)


import math
(n, m) = map(int, input().split())
d = list(map(int, input().split()))
m = m * 2
a = []
b = []
ans = ''
for i in d:
	c = 0
	z = []
	for e in a:
		if abs(i - e) <= m:
			q = math.sqrt(m ** 2 - (i - e) ** 2)
			r = b[c] + q
			z.append(r)
		c = c + 1
	if z != []:
		z = max(z)
		b.append(z)
		a.append(i)
		ans = ans + ' ' + str(z)
	if z == []:
		b.append(m / 2)
		a.append(i)
		ans = ans + ' ' + str(m / 2)
print(ans)


from collections import deque
from sys import stdin, stderr
lines = deque((line.strip() for line in stdin.readlines()))

def nextline():
	return lines.popleft()

def types(cast, sep=None):
	return tuple((cast(x) for x in nextline().split(sep=sep)))

def ints(sep=None):
	return types(int, sep=sep)

def strs(sep=None):
	return nextline().split(sep=sep)

def main():
	(n, r) = ints()
	xs = ints()
	ys = []
	hypot = 2 * r
	for i in range(n):
		y = r
		for j in range(i):
			if abs(xs[i] - xs[j]) <= hypot:
				x = xs[i] - xs[j]
				y = max((hypot * hypot - x * x) ** 0.5 + ys[j], y)
		ys.append(y)
	print(' '.join((str(y) for y in ys)))
main()


import sys
(n, r) = map(int, sys.stdin.readline().split())
x = list(map(int, sys.stdin.readline().split()))
y = [r]
for i in range(1, n):
	m = r
	for j in range(i):
		temp = 4 * r * r - (x[i] - x[j]) ** 2
		if temp >= 0:
			m = max(m, temp ** 0.5 + y[j])
	y.append(m)
for i in range(n):
	print(y[i], end=' ')
print()


import math
(n, r) = [int(i) for i in input().split()]
x = [int(i) for i in input().split()]
res = [r]
for i in range(1, n):
	y = r
	for j in range(0, i):
		if abs(x[j] - x[i]) <= 2 * r:
			y = max(y, math.sqrt((2 * r) ** 2 - (x[i] - x[j]) ** 2) + res[j])
	res.append(y)
for i in range(n):
	print(res[i], end=' ')


(n, r) = map(int, input().split())
x_coord = list(map(int, input().split()))
d = {}
for i in x_coord:
	final = r
	for j in range(i - r, i + r + 1):
		check = d.get(j, [-1, -1])
		if check[0] > 0:
			potential = check[1] + (4 * r * r - (i - check[0]) ** 2) ** 0.5
			final = max(potential, final)
	for j in range(i - r, i + r + 1):
		d[j] = (i, final)
	print(final, end=' ')


(n, r) = map(int, input().split())
s = list(map(int, input().split()))
l = [r]
for i in range(1, len(s)):
	b = r
	for j in range(i - 1, -1, -1):
		if abs(s[i] - s[j]) <= 2 * r:
			b = max(b, l[j] + (4 * r * r - (s[i] - s[j]) ** 2) ** 0.5)
	l.append(b)
print(*l)


import math
(n, r) = map(int, input().split())
v = []
for i in list(map(int, input().split())):
	my = r + 0
	for j in v:
		if j[0] < i and j[0] + r >= i - r or (j[0] >= i and j[0] - r <= i + r):
			y = j[1] + math.sqrt(4 * r * r - (j[0] - i) ** 2)
			if y > my:
				my = y
	v.append((i, my))
for i in v:
	print(i[1], end=' ')


from math import sqrt
(n, r) = map(int, input().split())
(dx, dy) = ([], [])
xs = list(map(int, input().split()))
for i in range(n):
	a = 1
	y = 0
	for j in range(i):
		if abs(xs[i] - dx[j]) <= 2 * r:
			a = 0
			y = max(round(dy[j] + sqrt((2 * r) ** 2 - (xs[i] - dx[j]) ** 2), 6), y)
	if a:
		dy.append(r)
	else:
		dy.append(y)
	dx.append(xs[i])
for i in dy:
	print(i, end=' ')


import sys
input = sys.stdin.readline
MOD = 1000000007
MOD2 = 998244353
ii = lambda : int(input().strip('\n'))
si = lambda : input().strip('\n')
dgl = lambda : list(map(int, input().strip('\n')))
f = lambda : map(int, input().strip('\n').split())
il = lambda : list(map(int, input().strip('\n').split()))
ls = lambda : list(input().strip('\n'))
let = 'abcdefghijklmnopqrstuvwxyz'
(n, r) = f()
l = il()
ans = [r]
for i in range(1, n):
	mx = r
	for j in range(i):
		if abs(l[j] - l[i]) <= 2 * r:
			mx = max(mx, ans[j] + (4 * r * r - (l[i] - l[j]) ** 2) ** 0.5)
	ans.append(mx)
print(*ans)


import math
(n, r) = map(int, input().split())
x = list(map(int, input().split()))
y = [r]
for i in range(1, len(x)):
	cur = r
	for j in range(i):
		d = abs(x[i] - x[j])
		if d <= 2 * r:
			cur = max(cur, y[j] + math.sqrt(4 * r ** 2 - d ** 2))
	y.append(cur)
print(*y)


import math
(n, r) = map(int, input().split())
x = list(map(int, input().split()))
y = []
for i in range(n):
	en = r
	for j in range(i):
		dx = math.fabs(x[j] - x[i])
		if dx <= 2 * r:
			en = max(en, y[j] + math.sqrt(4 * r * r - dx * dx))
	y.append(en)
for i in y:
	print(i, end=' ')


import itertools
(n, r) = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
ans = []
for i in range(0, n):
	y = r
	for j in range(0, i):
		if abs(A[i] - A[j]) <= 2 * r:
			y = max(y, ans[j] + ((2 * r) ** 2 - (A[j] - A[i]) ** 2) ** 0.5)
	ans.append(y)
[print(x, end=' ') for x in ans]


import math
(n, r) = map(int, input().split())
X = list(map(int, input().split()))
C = []
for q in range(len(X)):
	y = r
	for w in range(len(C)):
		if abs(X[w] - X[q]) <= 2 * r:
			yc = math.sqrt(4 * r * r - (X[w] - X[q]) ** 2) + C[w]
			y = max(y, yc)
	C.append(y)
print(*C)


f = lambda : map(int, input().split())
(n, r) = f()
(p, d) = ([], 2 * r)
for x in f():
	y = r
	for (a, b) in p:
		if abs(a - x) <= d:
			y = max(y, b + (d * d - (a - x) ** 2) ** 0.5)
	p.append((x, y))
for (x, y) in p:
	print(y)


from math import sqrt
(n, r) = list(map(int, input().split()))
x = list(map(int, input().split()))
y = []
for i in range(n):
	y.append(r)
	for j in range(i):
		d = abs(x[i] - x[j])
		if d > 2 * r:
			continue
		inc = sqrt(4 * r * r - d * d)
		y[i] = max(y[i], y[j] + inc)
print(' '.join(map(str, y)))


import bisect
(n, r) = input().split()
(n, r) = (int(n), int(r))
disks = list(map(int, input().split()))
d = dict()
final = []
for x in disks:
	first = bisect.bisect_left(final, x - 2 * r)
	last = bisect.bisect_right(final, x + 2 * r)
	m = 0
	for i in range(first, last):
		loc = final[i]
		if x - 2 * r <= loc <= x + 2 * r:
			m = max(m, (4 * r ** 2 - (x - loc) ** 2) ** 0.5 + d[loc])
	d[x] = m
	print(m + r, end=' ')
	bisect.insort(final, x)


import math
(n, r) = [int(s) for s in input().split()]
d = 2 * r
dd = d ** 2
x_coords = [int(s) for s in input().split()]
y_coords = [r]
for i in range(1, n):
	current_x = x_coords[i]
	condidates = []
	for j in range(i):
		if abs(current_x - x_coords[j]) <= d:
			condidates.append(j)
	if len(condidates) == 0:
		y_coords.append(r)
	elif len(condidates) == 1:
		x1 = x_coords[condidates[0]]
		y1 = y_coords[condidates[0]]
		dy = math.sqrt(dd - (current_x - x1) ** 2)
		y_coords.append(y1 + dy)
	else:
		y_condidates = []
		for condidate in condidates:
			x1 = x_coords[condidate]
			y1 = y_coords[condidate]
			dy = math.sqrt(dd - (current_x - x1) ** 2)
			y_condidates.append(y1 + dy)
		y_coords.append(max(y_condidates))
print(' '.join([str(y) for y in y_coords]))


(n, r) = map(int, input().split())
xs = list(map(float, input().split()))
ys = [0.0] * n
y = 0
for i in range(n):
	maxy = r
	for j in range(i):
		if abs(xs[j] - xs[i]) <= 2.0 * r:
			dx = xs[j] - xs[i]
			newy = (4 * r * r - dx * dx) ** 0.5 + ys[j]
			if maxy == -1 or maxy < newy:
				maxy = newy
	ys[i] = maxy
output = ' '.join(map(str, ys))
print(output)


import math
(n, r) = tuple((int(k) for k in input().split()))
xs = tuple(map(int, input().split()))
ts = []
for x2 in xs:
	y2 = r
	for (x1, y1) in ts:
		dx = abs(x1 - x2)
		if 2.0 * r - dx >= -0.001:
			y2 = max(y2, y1 + math.sqrt(4 * r ** 2 - dx ** 2))
	ts.append((x2, y2))
ys = [str(t[1]) for t in ts]
print(' '.join(ys))


from math import *
dis = []
ans = []
a = []
(n, r) = input().split()
n = int(n)
r = int(r)
for x in input().split():
	a.append(int(x))
for i in range(0, 1010):
	dis.append(-r)
for x in a:
	y = -r
	for k in range(max(1, x - 2 * r), min(1000, x + 2 * r) + 1):
		d = x - k
		y = max(y, sqrt(4 * r * r - d * d) + dis[k])
	dis[x] = y
	ans.append(y)
for i in range(0, n):
	print(ans[i])


(n, r) = map(int, input().split())
m = list(map(int, input().split()))
p = []
from math import fabs
for x in m:
	loc = r
	for (el, y) in p:
		if fabs(x - el) <= 2 * r:
			z = (4 * r ** 2 - fabs(x - el) ** 2) ** 0.5
			if z + y > loc:
				loc = z + y
	p.append([x, loc])
[print(i, end=' ') for (x, i) in p]


(n, r) = map(int, input().split())
x = list(map(int, input().split()))
y = [0] * n
y[0] = r
for i in range(1, n):
	temp = r
	for j in range(i):
		s = 4 * r * r - abs(x[j] - x[i]) * abs(x[j] - x[i])
		if s >= 0:
			temp = max(temp, s ** 0.5 + y[j])
	y[i] = temp
for i in range(n):
	y[i] = str(y[i])
print(' '.join(y))


import math as m
(nDiscs, r) = [int(x) for x in input().split()]
x = [int(x) for x in input().split()]
y = []
for i in range(len(x)):
	tempY = [r]
	for j in range(i):
		diffX = abs(x[i] - x[j])
		if diffX <= 2 * r:
			addY = m.sqrt(4 * r * r - diffX * diffX)
			tempY.append(y[j] + addY)
	y.append(max(tempY))
for i in range(len(y)):
	print(y[i], end=' ')
print()


import math
(n, r) = map(int, input().split())
dx = [int(num) for num in input().split()]
dy = [0.0 for num in range(0, n)]
y = 0
for i in range(0, n):
	ymx = r
	for j in range(0, i):
		if dx[j] - 2 * r <= dx[i] <= dx[j] + 2 * r:
			yd = dy[j] + math.sqrt(4.0 * r * r - pow(abs(dx[i] - dx[j]), 2))
			ymx = max(ymx, yd)
	dy[i] = ymx
print(str(dy).replace('[', '').replace(']', '').replace(',', ''))


from math import sqrt
(N, R) = [int(i) for i in input().split()]
X_LIST = [int(i) for i in input().split()]
y_list = [R]
for dropping in range(1, N):
	within_list = [i for i in range(0, dropping) if abs(X_LIST[i] - X_LIST[dropping]) <= 2 * R]
	if not within_list:
		y_list.append(R)
		continue
	y_list.append(max([y_list[i] + sqrt(4 * R ** 2 - abs(X_LIST[i] - X_LIST[dropping]) ** 2) for i in within_list]))
for y in y_list:
	print(y, end=' ')


import math
(n, r) = map(int, input().split())
a = [int(x) for x in input().split()]
ans = []
ans.append(r)
for x in range(1, len(a)):
	f = 0
	m = -9999999
	for x_ in range(x - 1, -1, -1):
		if abs(a[x] - a[x_]) <= 2 * r:
			m = max(m, ans[x_] + math.sqrt((2 * r) ** 2 - (a[x] - a[x_]) ** 2))
			f = 1
	if f == 0:
		ans.append(r)
	else:
		ans.append(m)
for i in range(len(ans)):
	print(ans[i], end=' ')


from math import sqrt
(n, r) = input().split(' ')
n = int(n)
r = float(r)
x = [float(num) for num in input().split(' ')]
y = [0] * n
for i in range(n):
	y[i] = r
	for j in range(i):
		if abs(x[j] - x[i]) <= 2 * r:
			p = sqrt(4 * r * r - (x[j] - x[i]) * (x[j] - x[i]))
			y[i] = max(y[i], y[j] + p)
	print(y[i], end=' ')


import sys
input = lambda : sys.stdin.readline().strip('\r\n')
(n, r) = map(int, input().split())
x = list(map(int, input().split()))
y = [0] * n
for i in range(n):
	cur = r
	for j in range(i):
		if 2 * r >= abs(x[i] - x[j]):
			cur = max(cur, y[j] + (4 * r * r - (x[i] - x[j]) ** 2) ** 0.5)
	y[i] = cur
print(*y)


import math

def C1():
	(n, r) = map(int, input().split())
	x_cord = [int(x) for x in input().split()]
	y_cord = []
	contactedDisk = 0
	for (i, x) in enumerate(x_cord):
		if len(y_cord) == 0:
			y_cord.append(r)
		else:
			y_cord.append(r)
			for j in range(i):
				diff = abs(x_cord[i] - x_cord[j])
				if diff <= 2 * r:
					y_cord[i] = max(y_cord[i], math.sqrt(4 * r * r - diff ** 2) + y_cord[j])
	for i in y_cord:
		print(i, end=' ')
C1()


import math
n_r = list(map(int, input().split()))
n = n_r[0]
radii = n_r[1]
x_list = list(map(int, input().split()))
temp_arr = []
for i in range(n):
	temp_arr.append(max([radii] + [math.sqrt(4 * radii ** 2 - (x_list[i] - x_list[j]) ** 2) + temp_arr[j] for j in range(i) if abs(x_list[i] - x_list[j]) <= 2 * radii]))
for i in temp_arr:
	print(i, end=' ')


import sys
import collections
import math
import random

def readInput():
	firstLine = input()
	secondLine = input()
	firstLine = firstLine.split()
	nrOfDiscs = int(firstLine[0])
	radius = int(firstLine[1])
	xPos = list(map(int, secondLine.split()))
	return (nrOfDiscs, radius, xPos)

def calc(xPos, radius):
	disksAtBottom = []
	for x in xPos:
		possHits = possibleCollisions(x, disksAtBottom, radius)
		if len(possHits) == 0:
			disksAtBottom.append((x, radius))
		else:
			hits = []
			highestHit = (x, radius)
			for bottomD in possHits:
				tmp = calcHitPoint(x, bottomD, radius)
				if tmp[1] > highestHit[1]:
					highestHit = tmp
			disksAtBottom.append(highestHit)
	yVals = [d[1] for d in disksAtBottom]
	return yVals

def possibleCollisions(discX, disksAtBottom, r):
	collis = []
	for d in disksAtBottom:
		if abs(discX - d[0]) <= 2 * r:
			collis.append(d)
	return collis

def calcHitPoint(discX, bottomDisc, r):
	xc = discX
	yc = 0
	dist = discX - bottomDisc[0]
	ang = math.acos(dist / (2 * r))
	xc = bottomDisc[0] + math.cos(ang) * 2 * r
	yc = bottomDisc[1] + math.sin(ang) * 2 * r
	return (xc, yc)

def test1():
	yPos = calc([5, 5, 6, 8, 3, 12], 2)
	expY = [2.0, 6.0, 9.87298334621, 13.3370849613, 12.5187346573, 13.3370849613]
	tol = 1e-06
	print(expY)
	print(yPos)
	for (i, value) in enumerate(yPos):
		print(f'Exp: {expY[i]}, Actual: {value}')
		if abs(value - expY[i]) > tol:
			print('Test failed!')
			break

def test2():
	(hx, hy) = calcHitPoint(5, (5, 1), 5)
	print(1)
	print((hx, hy))
	closeEnough(hx, 5)
	closeEnough(hy, 11)
	(hx, hy) = calcHitPoint(10, (0, 0), 5)
	print(2)
	print((hx, hy))
	closeEnough(hx, 10)
	closeEnough(hy, 0)
	(hx, hy) = calcHitPoint(0, (10, 0), 5)
	print(3)
	print((hx, hy))
	closeEnough(hx, 0)
	closeEnough(hy, 0)
	(hx, hy) = calcHitPoint(5, (0, 0), 5)
	print(4)
	print((hx, hy))

def test3():
	N = 1000
	r = 100
	xpos = []
	for i in range(N):
		xpos.append(random.randint(0, 999))
	ys = calc(xpos, r)
	print(' '.join(list(map(str, ys))))

def closeEnough(a, b):
	assert abs(a - b) < 1e-06

def main():
	(nrOfDiscs, radius, xPos) = readInput()
	ys = calc(xPos, radius)
	print(' '.join(list(map(str, ys))))
main()


import math
(n, r) = map(int, input().split())
a = list(map(int, input().split()))
ans = [r for x in range(n)]
for i in range(1, n):
	ans[i] = r
	for j in range(i):
		d = abs(a[i] - a[j])
		if d <= 2 * r:
			ans[i] = max(ans[i], ans[j] + math.sqrt(4 * r ** 2 - d ** 2))
print(*ans)


from math import pow, sqrt
(n, r) = [int(x) for x in input().split()]
xs = [int(x) for x in input().split()]
ys = []

def yoff(bottom_x: int, top_x: int) -> int:
	return sqrt(pow(2 * r, 2) - pow(abs(bottom_x - top_x), 2))
for i in range(n):
	y = r
	for j in range(i):
		if abs(xs[i] - xs[j]) <= 2 * r:
			y = max(ys[j] + yoff(xs[j], xs[i]), y)
	ys.append(y)
print(' '.join([str(y) for y in ys]))


from math import sqrt
(n, r) = map(int, input().split())
a = list(map(int, input().split()))
ret = [r] * n
for i in range(n):
	for j in range(i):
		dx = abs(a[i] - a[j])
		if dx <= 2 * r:
			ret[i] = max(ret[i], ret[j] + sqrt(4 * r ** 2 - dx ** 2))
print(*ret)