Everybody knows that the capital of Berland is connected to Bercouver (the Olympic capital) by a direct road. To improve the road's traffic capacity, there was placed just one traffic sign, limiting the maximum speed. Traffic signs in Berland are a bit peculiar, because they limit the speed only at that point on the road where they are placed. Right after passing the sign it is allowed to drive at any speed.

It is known that the car of an average Berland citizen has the acceleration (deceleration) speed of a km/h2, and has maximum speed of v km/h. The road has the length of l km, and the speed sign, limiting the speed to w km/h, is placed d km (1 ≤ d < l) away from the capital of Berland. The car has a zero speed at the beginning of the journey. Find the minimum time that an average Berland citizen will need to get from the capital to Bercouver, if he drives at the optimal speed.

The car can enter Bercouver at any speed.

Input

The first line of the input file contains two integer numbers a and v (1 ≤ a, v ≤ 10000). The second line contains three integer numbers l, d and w (2 ≤ l ≤ 10000; 1 ≤ d < l; 1 ≤ w ≤ 10000).

Output

Print the answer with at least five digits after the decimal point.

Examples

Input

1 1
2 1 3


Output

2.500000000000


Input

5 70
200 170 40


Output

8.965874696353

Source: codeforces | Difficulty: HARD
Tags: Mathematics

Implementation


Solutions:
import sys

def time_distance(v0, a, d):
	return (-v0 + (v0 ** 2 + 2 * a * d) ** 0.5) / a

def time_accelerating(v0, v1, a):
	return (v1 - v0) / a

def time_speed(v, d):
	return d / v

def distance_travelled(v0, t, a):
	return v0 * t + a / 2 * t ** 2

def main():
	(a, v) = map(int, sys.stdin.readline().strip().split())
	(l, d, w) = map(int, sys.stdin.readline().strip().split())
	time = 0
	time_to_d = time_distance(0, a, d)
	time_to_v = time_accelerating(0, v, a)
	if (v if time_to_v <= time_to_d else time_to_d * a) <= w:
		acceleration_time = time_to_v
		acceleration_distance = distance_travelled(0, acceleration_time, a)
		if acceleration_distance >= l:
			time = time_distance(0, a, l)
		else:
			time = acceleration_time
			time += time_speed(v, l - acceleration_distance)
	else:
		if time_to_v <= time_to_d:
			acceleration_time = time_to_v
			acceleration_distance = distance_travelled(0, acceleration_time, a)
			deceleration_time = time_accelerating(v, w, -a)
			deceleration_distance = distance_travelled(v, deceleration_time, -a)
		if time_to_v > time_to_d or acceleration_distance + deceleration_distance > d:
			acceleration_time = time_accelerating(0, w, a)
			acceleration_distance = distance_travelled(0, acceleration_time, a)
			remaining_distance = d - acceleration_distance
			delta_time = time_distance(w, a, remaining_distance / 2)
			time = acceleration_time + 2 * delta_time
		else:
			time = time_to_v
			time += time_speed(v, d - deceleration_distance - acceleration_distance)
			time += deceleration_time
		acceleration_time = time_accelerating(w, v, a)
		acceleration_distance = distance_travelled(w, acceleration_time, a)
		if acceleration_distance >= l - d:
			time += time_distance(w, a, l - d)
		else:
			time += acceleration_time
			time += time_speed(v, l - (d + acceleration_distance))
	sys.stdout.write('{0:.5f}'.format(time) + '\n')
main()


import math
SPACE = ' '

def get_data(file_name):
	result = list()
	state = 0
	data = list()
	try:
		for line in open(file_name, 'r').readlines():
			line = line.strip()
			if state == 0:
				if line == 'Input':
					data = list()
					state = 1
				elif line == 'Answer':
					state = 2
			elif state == 1:
				data += list(map(int, line.split(SPACE)))
				state = 11
			elif state == 11:
				data += list(map(int, line.split(SPACE)))
				state = 0
			elif state == 2:
				data.append(float(line))
				result.append(data)
				state = 0
	except FileNotFoundError:
		print(f'File {file_name} not found.')
	return result

def time(d=None, v=None, v0=0, steady=False):
	if steady:
		return d / v
	if d is None:
		return (v - v0) / ACCEL
	if v is None:
		v = vel(d=d, v0=v0)
	return 2 * d / (v + v0)

def dist(t=None, v=None, v0=0, steady=False):
	if steady:
		return v * t
	if t is None:
		return (pow(v, 2) - pow(v0, 2)) / (2 * ACCEL)
	return 1 / 2 * (v + v0) * t

def vel(d=None, t=None, v0=0, steady=False):
	if steady:
		return d / t
	if d is None:
		return t * ACCEL - v0
	return pow(2 * d * ACCEL + v0 ** 2, 1 / 2)

def can_ignore_sign(v, w, d):
	return v <= w or d <= dist(v=w)

def ignore_sign(v, w, l):
	dmax = dist(v=v)
	if l <= dmax:
		return time(d=l)
	return time(v=v) + time(d=l - dmax, v=v, steady=True)

def get_time(a, v, l, d, w):
	global ACCEL
	ACCEL = a
	if can_ignore_sign(v, w, d):
		return ignore_sign(v, w, l)
	(tmax, dmax) = (time(v=v), dist(v=v))
	(tlim_max, dlim_max) = (time(v=v, v0=w), dist(v=v, v0=w))
	if dmax + dlim_max <= d:
		res = tmax + time(d=d - dmax - dlim_max, v=v, steady=True) + tlim_max
	else:
		res = time(v=w) + time(v=vel(d=(d - dist(v=w)) / 2, v0=w), v0=w) * 2
	x = d + dist(v=v) - dist(v=w)
	if x >= l:
		res += time(d=l - d, v0=w)
		return res
	return res + time(v=v, v0=w) + time(d=l - x, v=v, steady=True)
(a, v) = map(int, input().split())
(l, d, w) = map(int, input().split())
print(get_time(a, v, l, d, w))


from math import *
(a, v) = list(map(int, input().split()))
(l, d, w) = list(map(int, input().split()))
if v > w:
	s1 = w ** 2 / 2 / a
	if d <= s1:
		s = min(v ** 2 / 2 / a, l)
		t = sqrt(2 * s / a) + (l - s) / v
	else:
		t = sqrt(2 * s1 / a)
		s2 = min((d - s1) / 2, (v ** 2 - w ** 2) / (2 * a))
		if s2 == (d - s1) / 2:
			t += 2 * (sqrt(2 * (s1 + s2) / a) - sqrt(2 * s1 / a))
		else:
			t += 2 * (v - w) / a + (d - s1 - 2 * s2) / v
		s3 = min((v ** 2 - w ** 2) / 2 / a, l - d)
		t += sqrt(2 * (s3 + s1) / a) - sqrt(2 * s1 / a) + (l - d - s3) / v
else:
	s = min(v ** 2 / 2 / a, l)
	t = sqrt(2 * s / a) + (l - s) / v
print(t)


import math
line = [float(x) for x in input().split()]
a = line[0]
v = line[1]
line = [float(x) for x in input().split()]
l = line[0]
d = line[1]
w = line[2]
t_to_top_speed = v / a
t_to_target = math.sqrt(2.0 * l / a)
t_to_speed_sign = math.sqrt(2.0 * d / a)
if w >= v or t_to_speed_sign <= w / a:
	if t_to_target <= t_to_top_speed:
		print(t_to_target)
	else:
		partial_distance = v * v / (2.0 * a)
		print(t_to_top_speed + (l - partial_distance) / v)
else:
	t_before_sign = 0.0
	t_to_speed_sign = math.sqrt(2 * w * w / (a * a) + 4 * d / a) - 2 * w / a
	if t_to_speed_sign <= 2.0 * (v - w) / a:
		t_to_w = w / a
		t_before_sign = t_to_w + t_to_speed_sign
	else:
		t_with_v = (d - v * v / a + w * w / (2.0 * a)) / v
		t_to_v = v / a
		t_to_deacc = (v - w) / a
		t_before_sign = t_to_v + t_with_v + t_to_deacc
	t_to_target = math.sqrt(w * w / (a * a) + 2.0 * (l - d) / a) - w / a
	t_to_v = (v - w) / a
	if t_to_v >= t_to_target:
		t_after_sign = t_to_target
	else:
		partial_distance = d + (v * v - w * w) / (2.0 * a)
		t_final = (l - partial_distance) / v
		t_after_sign = t_to_v + t_final
	print(t_before_sign + t_after_sign)


import math

def initial_calc_time(init_velocity, v, a, x):
	t = (v - init_velocity) / a
	init_distance = init_velocity * t + 0.5 * a * t * t
	if init_distance >= x:
		return (x, (math.sqrt(init_velocity * init_velocity + 2 * a * x) - init_velocity) / a)
	return (init_distance, t)

def calc_time(init_velocity, v, a, x):
	(init_distance, t) = initial_calc_time(init_velocity, v, a, x)
	return t + (x - init_distance) / v
(a, v) = map(int, input().split())
(l, d, w) = map(int, input().split())
if w > v:
	w = v
(x, t) = initial_calc_time(0, w, a, d)
if x == d:
	print('%.5f' % calc_time(0, v, a, l))
else:
	print('%.5f' % (t + calc_time(w, v, a, (d - x) * 0.5) * 2 + calc_time(w, v, a, l - d)))


from math import *
(a, vm) = map(int, input().split())
(l, d, vd) = map(int, input().split())
if vm <= vd or sqrt(2 * a * d) <= vd:
	if vm ** 2 / (2 * a) >= l:
		ans = sqrt(2 * l / a)
	else:
		ans = vm / a + (l - vm ** 2 / (2 * a)) / vm
else:
	s1 = (vm ** 2 - vd ** 2) / (2 * a)
	if s1 >= l - d:
		ans = (sqrt(4 * vd ** 2 + 8 * a * (l - d)) - 2 * vd) / (2 * a)
	else:
		ans = (vm - vd) / a + (l - d - s1) / vm
	v1 = sqrt((2 * a * d + vd ** 2) / 2)
	if v1 <= vm:
		ans = ans + v1 / a + (v1 - vd) / a
	else:
		s1 = d - (vm ** 2 - vd ** 2) / (2 * a) - vm ** 2 / (2 * a)
		ans = ans + vm / a + (vm - vd) / a + s1 / vm
print('%.12f' % ans)


(a, v) = map(int, input().split())
(l, d, w) = map(int, input().split())
(t1, t2) = (0, 0)
vt = (d * 2 * a) ** 0.5
v_max = min(v, w)
if vt < min(v, w):
	t1 = (2 * d / a) ** 0.5
	v_max = v
	v0 = vt
else:
	v_mid = min(((2 * a * d + v_max ** 2) * 0.5) ** 0.5, v)
	t1 = v_mid / a + (v_max - v_mid) / -a
	s1 = d - (2 * v_mid ** 2 - v_max ** 2) / 2 / a
	t1 += s1 / v_mid
	v0 = v_max
	v_max = v
d = l - d
vt = (v0 ** 2 + 2 * a * d) ** 0.5
if vt < v_max:
	t2 = 2 * d / (v0 + vt)
else:
	t2 = (v_max - v0) / a
	d -= (v_max + v0) / 2 * t2
	t2 += d / v_max
print('%.8f' % (t1 + t2))


(a, v) = list(map(int, input().split(' ')))
(l, d, w) = list(map(int, input().split(' ')))
if v <= w or w * w > 2 * a * d:
	if v * v > 2 * a * l:
		print((2 * l / a) ** 0.5)
	else:
		print(l / v + v / 2 / a)
else:
	u = (w * w / 2 + a * d) ** 0.5
	if u > v:
		m = v / a + (v - w) / a + (d - v * v / 2 / a - (v * v - w * w) / 2 / a) / v
	else:
		m = (2 * u - w) / a
	if v * v > 2 * a * (l - d + w * w / 2 / a):
		print(m - w / a + (2 * (l - d + w * w / 2 / a) / a) ** 0.5)
	else:
		print(m - w / a + (l - d + w * w / 2 / a) / v + v / 2 / a)


import logging
logging.basicConfig(level=logging.INFO)

def readintGenerator():
	while True:
		n = 0
		tmp = list(map(lambda x: int(x), input().split()))
		m = len(tmp)
		while n < m:
			yield tmp[n]
			n += 1
readint = readintGenerator()
a = next(readint)
v = next(readint)
l = next(readint)
d = next(readint)
w = next(readint)

def sqrt(x):
	return x ** 0.5

def cost(v0, l, v, a):
	s0 = (v ** 2 - v0 ** 2) / (2 * a)
	if s0 <= l:
		return (v - v0) / a + (l - s0) / v
	else:
		v1 = sqrt(v0 ** 2 + 2 * a * l)
		return (v1 - v0) / a

def calc(a, v, l, d, w):
	if v <= w:
		return cost(0, l, v, a)
	else:
		v0 = sqrt(2 * a * d)
		if v0 <= w:
			return cost(0, l, v, a)
		else:
			v1 = sqrt((2 * a * d + w ** 2) / 2)
			t0 = (2 * v1 - w) / a
			if v1 <= v:
				return t0 + cost(w, l - d, v, a)
			else:
				t0 = (d + (2 * v ** 2 - 2 * v * w + w ** 2) / (2 * a)) / v
				return t0 + cost(w, l - d, v, a)
print('%.8f' % calc(a, v, l, d, w))


from math import sqrt

def CF_5D():
	(a, v) = map(int, input().split())
	(l, d, w) = map(int, input().split())
	if v < w:
		w = v
	if v * v / (2 * a) + (v * v - w * w) / (2 * a) <= d:
		t1 = v / a
		s1 = v * v / (2 * a)
		t3 = (v - w) / a
		s3 = (v * v - w * w) / (2 * a)
		s2 = d - s1 - s3
		t2 = s2 / v
		s4 = l - s1 - s2 - s3
		if (v * v - w * w) / (2 * a) >= s4:
			t4 = (sqrt(2 * a * s4 + w * w) - w) / a
			t = t1 + t2 + t3 + t4
		else:
			t5 = (v - w) / a
			s5 = (v * v - w * w) / (2 * a)
			s6 = s4 - s5
			t6 = s6 / v
			t = t1 + t2 + t3 + t5 + t6
	elif w * w / (2 * a) >= d:
		if v * v / (2 * a) >= l:
			t = sqrt(2 * l / a)
		else:
			t1 = v / a
			t2 = (l - v * v / (2 * a)) / v
			t = t1 + t2
	else:
		s1 = (2 * a * d + w * w) / (4 * a)
		s2 = (2 * a * d - w * w) / (4 * a)
		s3 = l - s1 - s2
		t1 = sqrt(2 * s1 / a)
		t2 = t1 - w / a
		if (v * v - w * w) / (2 * a) >= s3:
			t3 = (sqrt(2 * a * s3 + w * w) - w) / a
			t = t1 + t2 + t3
		else:
			t4 = (v - w) / a
			s4 = (v * v - w * w) / (2 * a)
			s5 = s3 - s4
			t5 = s5 / v
			t = t1 + t2 + t4 + t5
	print(t)
	return
CF_5D()


from math import sqrt
(a, v) = map(int, input().split())
(l, d, w) = map(int, input().split())

def findt(u, v, a, dist):
	front = (v * v - u * u) / (2 * a)
	if front > dist:
		return (sqrt(u * u + 2 * a * dist) - u) / a
	return (v - u) / a + (dist - front) / v

def solve(a, v, l, d, w):
	if v <= w or 2 * a * d <= w * w:
		return findt(0, v, a, l)
	after = findt(w, v, a, l - d)
	peak = sqrt(a * d + w * w / 2)
	if peak > v:
		travel = (v * v - w * w / 2) / a
		before = (2 * v - w) / a + (d - travel) / v
	else:
		before = (2 * peak - w) / a
	return before + after
print(f'{solve(a, v, l, d, w):.8f}')


import math
(a, v) = map(float, input().split())
(l, d, w) = map(float, input().split())
ans = 0
if v < w:
	t0 = v / float(a)
	if a * pow(t0, 2) / 2 > l:
		ans = math.sqrt(2 * l / a)
	else:
		t1 = (l - a * t0 ** 2 / 2.0) / float(v)
		ans = t0 + t1
elif a * math.sqrt(2.0 * d / a) < w:
	t0 = v / a
	l1 = a * t0 ** 2 / 2
	if l1 >= l:
		ans = math.sqrt(2.0 * l / a)
	else:
		t1 = (l - l1) / float(v)
		ans = t0 + t1
else:
	t0 = math.sqrt((d + pow(w, 2) / (2 * a)) / a)
	if a * t0 < v:
		t1 = t0 - w / a
	else:
		t0 = v / a
		t1 = (v - w) / a
		t1 += (d - a * pow(t0, 2) / 2 - v * t1 + a * pow(t1, 2) / 2) / v
	t2 = (v - w) / a
	if w * t2 + a * t2 ** 2 / 2 > l - d:
		t2 = (-w + math.sqrt(math.pow(w, 2) - 2 * a * (d - l))) / a
		ans = t0 + t1 + t2
	else:
		t3 = (l - d - (w * t2 + a * t2 ** 2 / 2)) / v
		ans = t0 + t1 + t2 + t3
print(ans)


(a, v) = list(map(int, input().split(' ')))
(l, d, w) = list(map(int, input().split(' ')))
r = w * w / (2 * a)
if v <= w or r >= d:
	x = v * v / (2 * a)
	if x >= l:
		print((2 * l / a) ** 0.5)
	else:
		print(v / a + (l - x) / v)
else:
	if w * w + a * (d - r) < v * v:
		t = 2 * ((r + d) / a) ** 0.5 - w / a
	else:
		t = (d + r) / v + (v - w) / a
	x = (v * v - w * w) / (2 * a)
	l -= d
	if x >= l:
		t += (-w + (w * w + 2 * a * l) ** 0.5) / a
	else:
		t += (v - w) / a + (l - x) / v
	print(t)


def func(u, v, a, l):
	if v ** 2 - u ** 2 >= 2 * a * l:
		return ((u ** 2 + 2 * a * l) ** (1 / 2) - u) / a
	else:
		t1 = (v - u) / a
		t2 = (l - (u * t1 + a * t1 * t1 / 2)) / v
		return t1 + t2

def efficient(v, a, w, d):
	if 2 * v * v - w * w <= 2 * a * d:
		t1 = v / a
		t2 = (v - w) / a
		t3 = (d - 0.5 * a * t1 * t1 - v * t2 + 0.5 * a * t2 * t2) / v
		return t1 + t2 + t3
	else:
		bound = ((2 * a * d + w * w) / 2) ** 0.5
		t1 = bound / a
		t2 = (bound - w) / a
		t3 = func(0, w, a, d)
		return t1 + t2
		return min(t1 + t2, t3)

def main():
	string1 = input()
	string2 = input()
	arr1 = string1.split(' ')
	arr2 = string2.split(' ')
	a = int(arr1[0])
	v = int(arr1[1])
	l = int(arr2[0])
	d = int(arr2[1])
	w = int(arr2[2])
	if 2 * a * d <= w ** 2 or v <= w:
		t1 = func(0, v, a, l)
		print('%.8f' % t1)
	else:
		t1 = efficient(v, a, w, d)
		t2 = func(w, v, a, l - d)
		print('%.8f' % (t1 + t2))
main()


from math import sqrt

def main():
	(a, v) = map(int, input().split())
	(l, d, w) = map(int, input().split())
	if v <= w:
		w = v
	ax2 = a * 2
	vxv = v * v
	wxw = w * w
	ax2xd = ax2 * d
	if wxw >= ax2xd or v == w:
		if vxv <= ax2 * l:
			hours = v / a + (l - vxv / ax2) / v
		else:
			hours = sqrt(2.0 * l / a)
	else:
		vxv_wxw = vxv - wxw
		s = vxv + vxv_wxw
		if s <= ax2xd:
			p = v
			r = d - s / ax2
		else:
			p = sqrt((ax2xd + wxw) * 0.5)
			r = 0
		hours = (p + (p - w)) / a + r / p
		g = l - d
		s = ax2 * g
		if vxv_wxw >= s:
			hours += (sqrt(s + wxw) - w) / a
		else:
			hours += (v - w) / a + (g - vxv_wxw / ax2) / v
	print('{:.12f}'.format(hours))
main()


from math import sqrt
(a, v) = map(int, input().split())
(l, d, w) = map(int, input().split())
w = min(v, w)
lowtime = (v - w) / a
lowdist = v * lowtime - a * lowtime ** 2 / 2
startdist = v ** 2 / (2 * a)
if startdist + lowdist <= d:
	ans = v / a + (d - startdist - lowdist) / v + lowtime
elif w ** 2 <= 2 * d * a:
	u = sqrt(a * d + w ** 2 / 2)
	ans = (2 * u - w) / a
else:
	ans = sqrt(2 * d / a)
	w = ans * a
hightime = (v - w) / a
highdist = w * hightime + a * hightime ** 2 / 2
if highdist <= l - d:
	ans += hightime + (l - d - highdist) / v
else:
	disc = sqrt(w ** 2 + 2 * a * (l - d))
	ans += (disc - w) / a
print('%.7f' % ans)


import math

def getdt():
	return map(int, input().split())

def calc(v0, v, a, x):
	t = (v - v0) / a
	x0 = v0 * t + 0.5 * a * t * t
	if x0 >= x:
		return (x, (math.sqrt(v0 * v0 + 2 * a * x) - v0) / a)
	return (x0, t)

def go(v0, v, a, x):
	(x0, t) = calc(v0, v, a, x)
	return t + (x - x0) / v
(a, v) = getdt()
(l, d, w) = getdt()
if w > v:
	w = v
(x, t) = calc(0, w, a, d)
if x == d:
	print(go(0, v, a, l))
else:
	print(t + go(w, v, a, (d - x) * 0.5) * 2 + go(w, v, a, l - d))


from math import sqrt
import sys
from typing import List, Union

def rl(int_: bool=True, is_split: bool=True) -> Union[List[str], List[int]]:
	if int_:
		return [int(w) for w in sys.stdin.readline().split()]
	if is_split:
		return [w for w in sys.stdin.readline().split()]
	return sys.stdin.readline().strip()
(a, v) = rl()
(l, d, w) = rl()

def time(u, s, a, v):
	vs = sqrt(u * u + 2 * a * s)
	if vs <= v:
		return (vs - u) / a
	elif vs > v:
		dv = (v * v - u * u) / (2 * a)
		if dv >= s:
			vd = sqrt(u * u + 2 * a * s)
			return (vd - u) / a
		else:
			return (v - u) / a + (s - dv) / v
if w >= v:
	print(time(0, l, a, v))
elif w < v:
	vd = sqrt(2 * a * d)
	if vd <= w:
		print(time(0, l, a, v))
	elif vd > w:
		v_ = sqrt((w * w + 2 * a * d) / 2)
		if v_ <= v:
			td = v_ / a + (v_ - w) / a
		elif v_ > v:
			td = v / a + (d - (2 * v * v - w * w) / (2 * a)) / v + (v - w) / a
		print(td + time(w, l - d, a, v))


(a, v) = map(int, input().split())
(l, d, w) = map(int, input().split())
t = 0

def gett(a, b, c):
	delta = b ** 2 - 4 * a * c
	t1 = (-b + delta ** (1 / 2)) / (2 * a)
	t2 = (-b - delta ** (1 / 2)) / (2 * a)
	if min(t1, t2) > 0:
		return min(t1, t2)
	else:
		return max(t1, t2)
if 2 * a * d <= w * w or v <= w:
	if 2 * a * l <= v * v:
		t = (2 * l / a) ** (1 / 2)
	else:
		t = l / v + v / a / 2
else:
	tmp = d - 1 / 2 * v * v / a + 1 / 2 * (v - w) ** 2 / a - v * (v - w) / a
	if tmp <= 0:
		tmp2 = l - d - (1 / 2 * (v - w) ** 2 / a + w * (v - w) / a)
		if tmp2 >= 0:
			t = tmp2 / v + (v - w) / a + 2 * gett(a, 2 * w, w * w / (2 * a) - d) + w / a
		else:
			t = gett(a / 2, w, d - l) + 2 * gett(a, 2 * w, w * w / (2 * a) - d) + w / a
	else:
		tmp2 = l - d - (1 / 2 * (v - w) ** 2 / a + w * (v - w) / a)
		if tmp2 >= 0:
			t = tmp2 / v + (v - w) / a + (2 * v - w) / a + tmp / v
		else:
			t = gett(a / 2, w, d - l) + (2 * v - w) / a + tmp / v
print('%.12f' % t)


import os
import sys
from io import BytesIO, IOBase
import heapq as h
from bisect import bisect_left, bisect_right
import time
from types import GeneratorType
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		import os
		self.os = os
		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 = self.os.read(self._fd, max(self.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 = self.os.read(self._fd, max(self.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:
			self.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')
from collections import defaultdict as dd, deque as dq, Counter as dc
import string
from math import sqrt

def getInts():
	return [int(s) for s in input().split()]

def getInt():
	return int(input())

def getStrs():
	return [s for s in input().split()]

def getStr():
	return input()

def listStr():
	return list(input())

def getMat(n):
	return [getInts() for _ in range(n)]

def isInt(s):
	return '0' <= s[0] <= '9'
MOD = 10 ** 9 + 7

def t_from_s_a_u(s, a, u):
	return (-2 * u + sqrt(4 * u * u + 8 * s * a)) / (2 * a)

def solve():
	(A, V) = getInts()
	(L, D, W) = getInts()
	if V <= W or W ** 2 >= 2 * A * D:
		if V ** 2 >= 2 * A * L:
			return sqrt(2 * L / A)
		else:
			dist_1 = V ** 2 / (2 * A)
			T1 = 2 * dist_1 / V
			dist_2 = L - dist_1
			T2 = dist_2 / V
			return T1 + T2
	else:
		dist_1 = W ** 2 / (2 * A)
		T1 = sqrt(2 * dist_1 / A)
		rem_dist = D - dist_1
		dist_A = (V ** 2 - W ** 2) / (2 * A)
		if 2 * dist_A >= rem_dist:
			TA = 2 * t_from_s_a_u(rem_dist / 2, A, W)
		else:
			TA1 = 2 * (V - W) / A
			SA1 = (V + W) * (V - W) / A
			SA2 = rem_dist - SA1
			TA2 = SA2 / V
			TA = TA1 + TA2
		T1 += TA
		if V ** 2 - W ** 2 >= 2 * A * (L - D):
			return T1 + t_from_s_a_u(L - D, A, W)
		else:
			dist_2 = (V ** 2 - W ** 2) / (2 * A)
			T2 = 2 * dist_2 / (V + W)
			dist_3 = L - D - dist_2
			T3 = dist_3 / V
			return T1 + T2 + T3
	return
print(solve())


__author__ = 'Darren'

def solve():
	(a, v) = map(int, input().split())
	(l, d, w) = map(int, input().split())
	total_time = 0.0
	if v >= w:
		if w * w >= 2 * a * d:
			x = (2 * a * d) ** 0.5
			total_time = x / a
			if v * v - x * x >= 2 * a * (l - d):
				total_time += (-2 * x + (4 * x * x + 8 * a * (l - d)) ** 0.5) / (2 * a)
			else:
				total_time += (v - x) / a + (l - d - (v * v - x * x) / (2 * a)) / v
		else:
			if 2 * v * v - w * w <= 2 * a * d:
				total_time = v / a + (v - w) / a + (d - (2 * v * v - w * w) / (2 * a)) / v
			else:
				x = ((2 * a * d + w * w) / 2) ** 0.5
				total_time = x / a + (x - w) / a
			if v * v - w * w >= 2 * a * (l - d):
				total_time += (-2 * w + (4 * w * w + 8 * a * (l - d)) ** 0.5) / (2 * a)
			else:
				total_time += (v - w) / a + (l - d - (v * v - w * w) / (2 * a)) / v
	elif v * v >= 2 * a * l:
		total_time = (l * 2 / a) ** 0.5
	else:
		total_time = v / a + (l - v * v / (2 * a)) / v
	print('%.10f' % total_time)
solve()


from math import sqrt

def dist(speed, time):
	return speed * time + a * time ** 2 / 2

def travelTime(distance, speed):
	tAll = (-speed + sqrt(speed ** 2 + 2 * distance * a)) / a
	tMax = (v - speed) / a
	if tMax >= tAll:
		return tAll
	else:
		return tMax + (distance - dist(speed, tMax)) / v
(a, v) = map(int, input().split())
(l, d, w) = map(int, input().split())
if v <= w:
	print(travelTime(l, 0))
else:
	tw = w / a
	dw = dist(0, tw)
	if dw >= d:
		print(travelTime(l, 0))
	else:
		print(tw + 2 * travelTime((d - dw) / 2, w) + travelTime(l - d, w))


[a, v] = [eval(x) for x in str.split(input())]
[l, d, w] = [eval(x) for x in str.split(input())]
if v <= w:
	if v ** 2 >= 2 * a * l:
		t = (2 * l / a) ** 0.5
	else:
		s1 = v ** 2 / (2 * a)
		t1 = v / a
		s2 = l - s1
		t2 = s2 / v
		t = t1 + t2
elif w ** 2 >= 2 * a * d:
	if v ** 2 >= 2 * a * l:
		t = (2 * l / a) ** 0.5
	else:
		s1 = v ** 2 / (2 * a)
		t1 = v / a
		s2 = l - s1
		t2 = s2 / v
		t = t1 + t2
else:
	if (2 * a * d + w ** 2) / 2 <= v ** 2:
		v1 = ((2 * a * d + w ** 2) / 2) ** 0.5
		t1 = v1 / a
		t2 = (v1 - w) / a
	else:
		t1 = v / a + (v - w) / a
		t2 = (d - v ** 2 / (2 * a) - (v ** 2 - w ** 2) / (2 * a)) / v
	if v ** 2 - w ** 2 >= 2 * a * (l - d):
		t3 = (-w + (w ** 2 + 2 * a * (l - d)) ** 0.5) / a
		t = t1 + t2 + t3
	else:
		t3 = (v - w) / a
		s3 = w * t3 + a * t3 ** 2 / 2
		t4 = (l - d - s3) / v
		t = t1 + t2 + t3 + t4
print('%.10f' % t)


import math
(a, v) = map(float, input().split())
(l, d, w) = map(float, input().split())
res = 0.0
if v <= w:
	t1 = v / a
	d1 = 0.5 * a * t1 * t1
	if d1 >= l:
		res = math.sqrt(l * 2 / a)
	else:
		t2 = (l - d1) / v
		res = t1 + t2
else:
	t1 = w / a
	d1 = 0.5 * a * t1 * t1
	if d1 >= d:
		t1 = math.sqrt(d * 2 / a)
		cur = t1 * a
		t2 = (v - cur) / a
		d2 = 0.5 * a * t2 * t2 + cur * t2
		if d2 >= l - d:
			res = math.sqrt(l * 2 / a)
		else:
			t1 = v / a
			t2 = (l - 0.5 * a * t1 * t1) / v
			res = t1 + t2
	else:
		t1 = math.sqrt(d / a + w * w / (2 * a * a))
		t2 = (t1 * a - w) / a
		if t1 * a > v:
			t1 = v / a
			tx = (v - w) / a
			mid = d - 0.5 * a * t1 * t1 - (0.5 * -a * tx * tx + v * tx)
			t2 = tx + mid / v
		t3 = (v - w) / a
		d3 = 0.5 * a * t3 * t3 + w * t3
		if d3 >= l - d:
			t3 = (-w + math.sqrt(w * w - 4 * 0.5 * a * -(l - d))) / a
			res = t1 + t2 + t3
		else:
			t3 = (v - w) / a
			d3 = 0.5 * a * t3 * t3 + w * t3
			t4 = (l - d - d3) / v
			res = t1 + t2 + t3 + t4
print(res)


from sys import stdin, stderr
from math import sqrt
EPS = 1e-09

def position_at_time(t, acceletarion, initial_speed, initial_position):
	return 0.5 * acceletarion * t * t + initial_speed * t + initial_position

def time_to_reach_speed(final_speed, initial_speed, acceletarion):
	return abs(float(final_speed - initial_speed)) / acceletarion

def time_to_travel_distance(distance_to_travel, initial_speed, acceletarion):
	return (-initial_speed + sqrt(initial_speed * initial_speed + 2 * acceletarion * distance_to_travel)) / acceletarion
(a, v) = map(int, stdin.readline().split())
(l, d, w) = map(int, stdin.readline().split())
res = 0.0
vd = w
if w >= v:
	t = time_to_reach_speed(v, 0, a)
	x = position_at_time(t, a, 0, 0)
	if x >= d - EPS:
		t = time_to_travel_distance(d, 0, a)
		res += t
		vd = a * t
	else:
		res += t + (d - x) / v
		vd = v
else:
	t = time_to_reach_speed(w, 0, a)
	x = position_at_time(t, a, 0, 0)
	if x >= d - EPS:
		t = time_to_travel_distance(d, 0, a)
		res += t
		vd = a * t
	else:
		ts = time_to_reach_speed(v, 0, a)
		ds = position_at_time(ts, a, 0, 0)
		tf = time_to_reach_speed(v, w, a)
		df = position_at_time(tf, a, w, 0)
		if ds + df <= d + EPS:
			res = ts + (d - ds - df) / v + tf
		else:
			lo = w
			hi = v
			for tt in range(80):
				mid = (lo + hi) / 2.0
				ts = time_to_reach_speed(mid, 0, a)
				ds = position_at_time(ts, a, 0, 0)
				tf = time_to_reach_speed(mid, w, a)
				df = position_at_time(tf, -a, mid, 0)
				if ds + df > d + EPS:
					hi = mid
				else:
					lo = mid
			res = time_to_reach_speed(lo, 0, a) + time_to_reach_speed(lo, w, a)
		vd = w
t = time_to_reach_speed(v, vd, a)
x = position_at_time(t, a, vd, d)
if x >= l - EPS:
	res += time_to_travel_distance(l - d, vd, a)
else:
	res += t + (l - x) / v
print('%.12f' % res)