In this problem we consider a very simplified model of Barcelona city.

Barcelona can be represented as a plane with streets of kind $x = c$ and $y = c$ for every integer $c$ (that is, the rectangular grid). However, there is a detail which makes Barcelona different from Manhattan. There is an avenue called Avinguda Diagonal which can be represented as a the set of points $(x, y)$ for which $ax + by + c = 0$.

One can walk along streets, including the avenue. You are given two integer points $A$ and $B$ somewhere in Barcelona. Find the minimal possible distance one needs to travel to get to $B$ from $A$.


-----Input-----

The first line contains three integers $a$, $b$ and $c$ ($-10^9\leq a, b, c\leq 10^9$, at least one of $a$ and $b$ is not zero) representing the Diagonal Avenue.

The next line contains four integers $x_1$, $y_1$, $x_2$ and $y_2$ ($-10^9\leq x_1, y_1, x_2, y_2\leq 10^9$) denoting the points $A = (x_1, y_1)$ and $B = (x_2, y_2)$.


-----Output-----

Find the minimum possible travel distance between $A$ and $B$. Your answer is considered correct if its absolute or relative error does not exceed $10^{-6}$.

Formally, let your answer be $a$, and the jury's answer be $b$. Your answer is accepted if and only if $\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6}$.


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

Output
4.2426406871

Input
3 1 -9
0 3 3 -1

Output
6.1622776602



-----Note-----

The first example is shown on the left picture while the second example us shown on the right picture below. The avenue is shown with blue, the origin is shown with the black dot. [Image]

Difficulty: HARD
Tags: Geometry

Implementation

Starter code:

Solutions:
from math import sqrt

def sqr(a):
	return a * a
(a, b, c) = [float(i) for i in input().split()]
(x1, y1, x2, y2) = [float(i) for i in input().split()]
if a == 0 or b == 0:
	print(abs(x1 - x2) + abs(y1 - y2))
	return
c1_y = -(a * x1 + c) / b
c2_y = -(a * x2 + c) / b
c1_x = -(b * y1 + c) / a
c2_x = -(b * y2 + c) / a
ans = abs(x1 - x2) + abs(y1 - y2)
now = abs(c1_y - y1) + sqrt(sqr(x1 - c2_x) + sqr(c1_y - y2)) + abs(c2_x - x2)
ans = min(ans, now)
now = abs(c1_y - y1) + sqrt(sqr(x1 - x2) + sqr(c1_y - c2_y)) + abs(c2_y - y2)
ans = min(ans, now)
now = abs(c1_x - x1) + sqrt(sqr(c1_x - c2_x) + sqr(y1 - y2)) + abs(c2_x - x2)
ans = min(ans, now)
now = abs(c1_x - x1) + sqrt(sqr(c1_x - x2) + sqr(y1 - c2_y)) + abs(c2_y - y2)
ans = min(ans, now)
print('%.30f' % ans)


(a, b, c) = map(int, input().split())
(x1, y1, x2, y2) = map(int, input().split())
bRange = abs(y2 - y1) + abs(x2 - x1)
if a == 0 or b == 0:
	print(bRange)
else:
	py1 = (-b * y1 - c) / a
	py2 = (-b * y2 - c) / a
	px1 = (-a * x1 - c) / b
	px2 = (-a * x2 - c) / b
	pRange1 = ((x2 - py1) ** 2 + (px2 - y1) ** 2) ** 0.5 + abs(y2 - px2) + abs(py1 - x1)
	pRange2 = ((py2 - py1) ** 2 + (y2 - y1) ** 2) ** 0.5 + abs(py1 - x1) + abs(x2 - py2)
	pRange3 = ((x2 - x1) ** 2 + (px2 - px1) ** 2) ** 0.5 + abs(px1 - y1) + abs(y2 - px2)
	pRange4 = ((py2 - x1) ** 2 + (y2 - px1) ** 2) ** 0.5 + abs(px1 - y1) + abs(x2 - py2)
	print(min(bRange, pRange1, pRange2, pRange3, pRange4))


from fractions import Fraction
(a, b, c) = map(int, input().split())
(x1, y1, x2, y2) = map(int, input().split())
(x3, y3, x4, y4) = (x1, y2, x2, y1)
if (y2 - y1) * (x2 - x1) * a * b >= 0 or ((a * x1 + b * y1 + c) * (a * x3 + b * y3 + c) > 0 and (a * x1 + b * y1 + c) * (a * x4 + b * y4 + c) > 0):
	print(abs(y2 - y1) + abs(x2 - x1))
else:
	y5 = Fraction(-(a * x1 + c), b)
	if (y5 - y1) * (y5 - y2) <= 0:
		x5 = x1
	else:
		x5 = Fraction(-(b * y1 + c), a)
		y5 = y1
	y6 = Fraction(-(a * x2 + c), b)
	if (y6 - y2) * (y6 - y1) <= 0:
		x6 = x2
	else:
		x6 = Fraction(-(b * y2 + c), a)
		y6 = y2
	print(abs(y2 - y1) + abs(x2 - x1) - abs(y6 - y5) - abs(x6 - x5) + ((y6 - y5) ** 2 + (x6 - x5) ** 2) ** 0.5)


import math
(a, b, c) = [int(i) for i in input().split()]
(x1, y1, x2, y2) = [int(i) for i in input().split()]
l1 = abs(x1 - x2) + abs(y1 - y2)
if a == 0 or b == 0:
	print(l1)
	return
xa = -(b * y1 + c) / a
ya = y1
xb = x1
yb = -(a * x1 + c) / b
xc = -(b * y2 + c) / a
yc = y2
xd = x2
yd = -(a * x2 + c) / b
l2 = abs(x1 - xa) + math.sqrt((xa - xc) ** 2 + (ya - yc) ** 2) + abs(xc - x2)
l3 = abs(x1 - xa) + math.sqrt((xa - xd) ** 2 + (ya - yd) ** 2) + abs(yd - y2)
l4 = abs(y1 - yb) + math.sqrt((xb - xc) ** 2 + (yb - yc) ** 2) + abs(xc - x2)
l5 = abs(y1 - yb) + math.sqrt((xb - xd) ** 2 + (yb - yd) ** 2) + abs(yd - y2)
print(min(l1, l2, l3, l4, l5))


from math import *
(a, b, c) = list(map(int, input().split()))
(x1, y1, x2, y2) = list(map(int, input().split()))
m = -1
if a == 0 or b == 0:
	print(abs(x2 - x1) + abs(y2 - y1))
else:
	tr = [[[x1, (a * x1 + c) / -b], [(b * y1 + c) / -a, y1]], [[x2, (a * x2 + c) / -b], [(b * y2 + c) / -a, y2]]]
	for i in range(2):
		for j in range(2):
			sqr = sqrt((tr[0][i][0] - tr[1][j][0]) * (tr[0][i][0] - tr[1][j][0]) + (tr[0][i][1] - tr[1][j][1]) * (tr[0][i][1] - tr[1][j][1]))
			if m == -1:
				m = abs(x1 - tr[0][i][0]) + abs(y1 - tr[0][i][1]) + abs(x2 - tr[1][j][0]) + abs(y2 - tr[1][j][1]) + sqr
			else:
				m = min(abs(x1 - tr[0][i][0]) + abs(y1 - tr[0][i][1]) + abs(x2 - tr[1][j][0]) + abs(y2 - tr[1][j][1]) + sqr, m)
	print(min(m, abs(x2 - x1) + abs(y2 - y1)))


import math

def lll(a, b):
	return math.sqrt((b[0] - a[0]) ** 2 + (b[1] - a[1]) ** 2)

def III(a, b):
	return abs(b[0] - a[0]) + abs(b[1] - a[1])
(a, b, c) = map(int, input().split())
(x1, y1, x2, y2) = map(int, input().split())
g = [[]] * 8
for i in range(8):
	g[i] = [float('inf')] * 8
p = [(x1, y1), (x1, y2), (x2, y2), (x2, y1)]
l = []
if a != 0 and b != 0:
	l = [(x1, (-a * x1 - c) / b), ((-b * y1 - c) / a, y1), (x2, (-a * x2 - c) / b), ((-b * y2 - c) / a, y2)]
else:
	l = [(x1, y1), (x1, y1), (x1, y1), (x1, y1)]
for i in range(4):
	for j in range(4):
		g[i][4 + j] = g[4 + j][i] = III(p[i], l[j])
		if i != j:
			g[i][j] = g[j][i] = III(p[i], p[j])
			g[4 + i][4 + j] = g[4 + j][4 + i] = lll(l[i], l[j])
ls = [float('inf')] * 8
ls[0] = 0
qu = [0]
while len(qu) > 0:
	i = qu[0]
	qu = qu[1:]
	for j in range(8):
		if ls[i] + g[i][j] < ls[j]:
			ls[j] = ls[i] + g[i][j]
			if not j in qu:
				qu += [j]
print(ls[2])


(a, b, c) = map(int, input().split())
(x1, y1, x2, y2) = map(int, input().split())
if x1 >= x2 and y1 >= y2:
	(x1, y1, x2, y2) = (x2, y2, x1, y1)
if x1 <= x2 and y1 >= y2:
	x2 = x1 - (x2 - x1)
	c += 2 * x1 * a
	a = -a
	(x1, y1, x2, y2) = (x2, y2, x1, y1)
if x1 >= x2 and y1 <= y2:
	x1 = x2 - (x1 - x2)
	c += 2 * x2 * a
	a = -a
ans = x2 - x1 + y2 - y1
if a == 0 or b == 0:
	print(ans)
else:
	yab = -(c + a * x1) * abs(a) * (b // abs(b))
	ybb = -(c + a * x2) * abs(a) * (b // abs(b))
	xaa = -(c + b * y1) * abs(b) * (a // abs(a))
	xba = -(c + b * y2) * abs(b) * (a // abs(a))
	y1 *= abs(a * b)
	y2 *= abs(a * b)
	x1 *= abs(a * b)
	x2 *= abs(a * b)
	if y1 <= yab <= y2 and yab <= ybb:
		if ybb <= y2:
			ans = (yab - y1 + y2 - ybb + ((ybb - yab) * (ybb - yab) + (x2 - x1) * (x2 - x1)) ** 0.5) / abs(a * b)
		else:
			ans = (yab - y1 + x2 - xba + ((y2 - yab) * (y2 - yab) + (xba - x1) * (xba - x1)) ** 0.5) / abs(a * b)
		print(ans)
	elif x1 <= xaa <= x2 and xaa <= xba:
		if xba <= x2:
			ans = (xaa - x1 + x2 - xba + ((xba - xaa) * (xba - xaa) + (y2 - y1) * (y2 - y1)) ** 0.5) / abs(a * b)
		else:
			ans = (xaa - x1 + y2 - ybb + ((x2 - xaa) * (x2 - xaa) + (ybb - y1) * (ybb - y1)) ** 0.5) / abs(a * b)
		print(ans)
	else:
		print(ans)


from math import sqrt
(a, b, c) = list(map(int, input().split()))
(x1, y1, x2, y2) = list(map(int, input().split()))
res1 = abs(x1 - x2) + abs(y1 - y2)
res2 = 10 ** 10 + 7
res3 = 10 ** 10 + 7
res4 = 10 ** 10 + 7
res5 = 10 ** 10 + 7
if b != 0 and a != 0:
	x = (-y1 * b - c) / a
	y = (-x2 * a - c) / b
	res2 = abs(x1 - x) + abs(y2 - y) + sqrt(abs(x - x2) ** 2 + abs(y1 - y) ** 2)
if a != 0:
	x = (-y1 * b - c) / a
	xx = (-y2 * b - c) / a
	res4 = abs(x1 - x) + abs(x2 - xx) + sqrt(abs(x - xx) ** 2 + abs(y1 - y2) ** 2)
if b != 0:
	y = (-x1 * a - c) / b
	yy = (-x2 * a - c) / b
	res5 = abs(y1 - y) + abs(y2 - yy) + sqrt(abs(y - yy) ** 2 + abs(x1 - x2) ** 2)
if a != 0 and b != 0:
	x = (-y2 * b - c) / a
	y = (-x1 * a - c) / b
	res3 = abs(y1 - y) + abs(x2 - x) + sqrt(abs(x1 - x) ** 2 + abs(y2 - y) ** 2)
print(min(res1, res2, res3, res4, res5))


import math
(a, b, c) = list(map(int, input().split()))
(ax, ay, bx, by) = list(map(int, input().split()))
if a == 0 or b == 0:
	print(abs(ax - bx) + abs(ay - by))
	return
oy = -(a * ax + c) / b
ty = -(a * bx + c) / b
ox = -(b * ay + c) / a
tx = -(b * by + c) / a
ans = abs(ax - bx) + abs(ay - by)
ans1 = abs(ay - oy) + abs(by - ty) + math.sqrt(abs(ax - bx) ** 2 + abs(oy - ty) ** 2)
ans2 = abs(ax - ox) + abs(bx - tx) + math.sqrt(abs(ay - by) ** 2 + abs(ox - tx) ** 2)
ans3 = abs(ax - ox) + abs(by - ty) + math.sqrt(abs(bx - ox) ** 2 + abs(ay - ty) ** 2)
ans4 = abs(ay - oy) + abs(bx - tx) + math.sqrt(abs(by - oy) ** 2 + abs(ax - tx) ** 2)
print(min(ans, ans1, ans2, ans3, ans4))


def y(x):
	return -(a * x + c) / b

def x(y):
	return -(b * y + c) / a
(a, b, c) = map(int, input().split())
(x1, y1, x2, y2) = map(int, input().split())
taxi_path = abs(x1 - x2) + abs(y1 - y2)
if a == 0 or b == 0:
	print(taxi_path)
else:
	av_1 = abs(x1 - x(y1)) + pow(abs(x(y1) - x(y2)) ** 2 + abs(y1 - y2) ** 2, 0.5) + abs(x(y2) - x2)
	av_2 = abs(x1 - x(y1)) + pow(abs(x(y1) - x2) ** 2 + abs(y1 - y(x2)) ** 2, 0.5) + abs(y(x2) - y2)
	av_3 = abs(y1 - y(x1)) + pow(abs(x1 - x(y2)) ** 2 + abs(y(x1) - y2) ** 2, 0.5) + abs(x(y2) - x2)
	av_4 = abs(y1 - y(x1)) + pow(abs(y(x1) - y(x2)) ** 2 + abs(x1 - x2) ** 2, 0.5) + abs(y(x2) - y2)
	print(min(taxi_path, av_1, av_2, av_3, av_4))


import math

def rst(A, B):
	x1 = A[0]
	y1 = A[1]
	x2 = B[0]
	y2 = B[1]
	return math.sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2)
(a, b, c) = list(map(float, input().split()))
(x1, y1, x2, y2) = list(map(float, input().split()))
l = []
if a == 0 or b == 0:
	print(abs(x2 - x1) + abs(y1 - y2))
else:
	st = (x1, y1)
	fn = (x2, y2)
	xa = x1
	ya = (-c - a * x1) / b
	A = (xa, ya)
	xb = x2
	yb = (-c - a * x2) / b
	B = (xb, yb)
	xc = (-c - b * y1) / a
	yc = y1
	C = (xc, yc)
	xd = (-c - b * y2) / a
	yd = y2
	D = (xd, yd)
	print(min(abs(x2 - x1) + abs(y1 - y2), rst(st, A) + rst(A, B) + rst(B, fn), rst(st, A) + rst(A, D) + rst(D, fn), rst(st, C) + rst(C, B) + rst(B, fn), rst(st, C) + rst(C, D) + rst(D, fn)))


(a, b, c) = map(int, input().split())
(x1, y1, x2, y2) = map(int, input().split())
l = 0
xz1 = x1
if b != 0:
	yz1 = (-c - x1 * a) / b
else:
	yz1 = 9999999999999999999
if a != 0:
	xz2 = (-c - y1 * b) / a
else:
	xz2 = 9999999999999999999
yz2 = y1
xf1 = x2
if b != 0:
	yf1 = (-c - x2 * a) / b
else:
	yf1 = 9999999999999999999
if a != 0:
	xf2 = (-c - y2 * b) / a
else:
	xf2 = 9999999999999999999
yf2 = y2
v1 = abs(x1 - x2) + abs(y1 - y2)
v2 = abs(xz1 - x1) + abs(yz1 - y1) + abs(xf1 - x2) + abs(yf1 - y2) + ((xz1 - xf1) ** 2 + (yz1 - yf1) ** 2) ** 0.5
v3 = abs(xz1 - x1) + abs(yz1 - y1) + abs(xf2 - x2) + abs(yf2 - y2) + ((xz1 - xf2) ** 2 + (yz1 - yf2) ** 2) ** 0.5
v4 = abs(xz2 - x1) + abs(yz2 - y1) + abs(xf1 - x2) + abs(yf1 - y2) + ((xz2 - xf1) ** 2 + (yz2 - yf1) ** 2) ** 0.5
v5 = abs(xz2 - x1) + abs(yz2 - y1) + abs(xf2 - x2) + abs(yf2 - y2) + ((xz2 - xf2) ** 2 + (yz2 - yf2) ** 2) ** 0.5
print(min(v1, v2, v3, v4, v5))


from math import ceil, floor
(a, b, c) = (int(e) for e in input().split(' '))
(x1, y1, x2, y2) = (int(e) for e in input().split(' '))

def dist(x1, y1, x2, y2):
	return ((x1 - x2) ** 2 + (y1 - y2) ** 2) ** 0.5

def m_dist(x1, y1, x2, y2):
	return abs(x1 - x2) + abs(y1 - y2)

def project(x, y):
	if a == 0 and b == 0:
		return (float('inf'), float('inf'))
	return ((-c * a + b * b * x - a * b * y) / (a * a + b * b), (-a * b * x + a * a * y - b * c) / (a * a + b * b))

def x_to_y(x):
	if b == 0:
		return float('inf')
	return (-c - a * x) / b

def y_to_x(y):
	if a == 0:
		return float('inf')
	return (-c - b * y) / a
(point1x, point1y) = project(x1, y1)
point1s = []
t = ceil(point1x)
point1s.append((t, x_to_y(t)))
t = floor(point1x)
point1s.append((t, x_to_y(t)))
t = ceil(point1y)
point1s.append((y_to_x(t), t))
t = floor(point1y)
point1s.append((y_to_x(t), t))
point1s.append((y_to_x(y1), y1))
point1s.append((x1, x_to_y(x1)))
(point2x, point2y) = project(x2, y2)
point2s = []
t = ceil(point2x)
point2s.append((t, x_to_y(t)))
t = floor(point2x)
point2s.append((t, x_to_y(t)))
t = ceil(point2y)
point2s.append((y_to_x(t), t))
t = floor(point2y)
point2s.append((y_to_x(t), t))
point2s.append((y_to_x(y2), y2))
point2s.append((x2, x_to_y(x2)))
res = m_dist(x1, y1, x2, y2)
for p1 in point1s:
	for p2 in point2s:
		t = m_dist(x1, y1, p1[0], p1[1])
		t += dist(p1[0], p1[1], p2[0], p2[1])
		t += m_dist(x2, y2, p2[0], p2[1])
		if res > t:
			res = t
print(res)


def left_is_not(fet, tip):
	s = 0
	fet += 1
	if tip == 0:
		fet = tip + 10
	return tip
(a, b, c) = list(map(int, input().split()))
(x1, y1, x2, y2) = list(map(int, input().split()))
l = []
l.append(abs(y1 - y2) + abs(x1 - x2))
if a == 0 or b == 0:
	print(abs(y1 - y2) + abs(x1 - x2))
else:
	xA = (-b * y1 - c) / a
	xB = (-b * y2 - c) / a
	yA = (-a * x1 - c) / b
	yB = (-a * x2 - c) / b
	l.append(((xA - xB) ** 2 + (y1 - y2) ** 2) ** 0.5 + abs(x1 - xA) + abs(x2 - xB))
	l.append(((x1 - x2) ** 2 + (yA - yB) ** 2) ** 0.5 + abs(y1 - yA) + abs(y2 - yB))
	l.append(((x1 - xB) ** 2 + (yA - y2) ** 2) ** 0.5 + abs(yA - y1) + abs(x2 - xB))
	l.append(((xA - x2) ** 2 + (y1 - yB) ** 2) ** 0.5 + abs(x1 - xA) + abs(y2 - yB))
	print(min(l))


import math
l1 = 0
l2 = 0
l3 = 0
l4 = 0
l5 = 0
(a, b, c) = map(int, input().split())
(x1, y1, x2, y2) = map(int, input().split())
l = 0
if a != 0 and b != 0:
	if x1 == x2:
		r = max(y1, y2) - min(y1, y2)
	elif y1 == y2:
		r = max(x1, x2) - min(x1, x2)
	else:
		x0 = -1 * (b * y1 + c) / a
		y0 = y1
		l1 += math.fabs(-1 * (b * y1 + c) / a - x1)
		x3 = x1
		y3 = -1 * (a * x1 + c) / b
		l2 += math.fabs(-1 * (a * x1 + c) / b - y1)
		xk = -1 * (b * y2 + c) / a
		yk = y2
		l3 += math.fabs(-1 * (b * y2 + c) / a - x2)
		xk1 = x2
		yk1 = -1 * (a * x2 + c) / b
		l4 += math.fabs(-1 * (a * x2 + c) / b - y2)
		m1 = l1 + l3 + ((x0 - xk) ** 2 + (y0 - yk) ** 2) ** 0.5
		m2 = l2 + l3 + ((x3 - xk) ** 2 + (y3 - yk) ** 2) ** 0.5
		m3 = l1 + l4 + ((x0 - xk1) ** 2 + (y0 - yk1) ** 2) ** 0.5
		m4 = l2 + l4 + ((x3 - xk1) ** 2 + (y3 - yk1) ** 2) ** 0.5
		l5 = math.fabs(x1 - x2) + math.fabs(y1 - y2)
		l = min(m1, min(m2, min(m3, min(m4, l5))))
else:
	l = math.fabs(x1 - x2) + math.fabs(y1 - y2)
print(l)


from math import *

def r(x1, y1, x2, y2):
	return (abs(x1 - x2) ** 2 + abs(y1 - y2) ** 2) ** 0.5
(a, b, c) = map(int, input().split())
(x1, y1, x2, y2) = map(int, input().split())
r1 = abs(x1 - x2) + abs(y1 - y2)
if a == 0 or b == 0:
	print(r1)
else:
	k = -a / b
	b = -c / b
	x01 = x1
	y01 = k * x1 + b
	x02 = (y2 - b) / k
	y02 = y2
	x03 = x2
	y03 = k * x2 + b
	x04 = (y1 - b) / k
	y04 = y1
	r2 = r(x1, y1, x01, y01) + r(x01, y01, x02, y02) + r(x02, y02, x2, y2)
	r3 = r(x1, y1, x01, y01) + r(x01, y01, x03, y03) + r(x03, y03, x2, y2)
	r12 = r(x1, y1, x04, y04) + r(x04, y04, x02, y02) + r(x02, y02, x2, y2)
	r13 = r(x1, y1, x04, y04) + r(x04, y04, x03, y03) + r(x03, y03, x2, y2)
	print(min(r1, r2, r3, r12, r13))


import math
(a, b, c) = map(int, input().split())
(x1, y1, x2, y2) = map(int, input().split())
s = abs(x1 - x2) + abs(y1 - y2)
if a != 0:
	xk1 = -1 * (b * y1 + c) / a
	xk2 = -1 * (b * y2 + c) / a
else:
	xk1 = 10 ** 18
	xk2 = 10 ** 18
if b != 0:
	yk1 = -1 * (a * x1 + c) / b
	yk2 = -1 * (a * x2 + c) / b
else:
	yk1 = 10 ** 18
	yk2 = 10 ** 18
lx1 = abs(y1 - yk1)
lx2 = abs(y2 - yk2)
ly1 = abs(x1 - xk1)
ly2 = abs(x2 - xk2)
s1 = math.sqrt((x1 - x2) ** 2 + (yk1 - yk2) ** 2)
s2 = math.sqrt((x1 - xk1) ** 2 + (yk1 - y1) ** 2)
s3 = math.sqrt((x1 - xk2) ** 2 + (yk1 - y2) ** 2)
s4 = math.sqrt((xk1 - x2) ** 2 + (y1 - yk2) ** 2)
s5 = math.sqrt((x2 - xk2) ** 2 + (y2 - yk2) ** 2)
s6 = math.sqrt((xk1 - xk2) ** 2 + (y1 - y2) ** 2)
s = min(s, lx1 + lx2 + s1, lx1 + s3 + ly2, ly1 + s4 + lx2, ly1 + s6 + ly2)
print(s)


import math

class vector:

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

	def sum(self, vector):
		return 1

	def len(self):
		return math.sqrt(self.x * self.x + self.y * self.y)

	def __str__(self):
		return str(self.x) + ' ' + str(self.y)

	def __add__(self, other):
		return vector(self.x + other.x, self.y + other.y)

	def __sub__(self, other):
		return vector(self.x - other.x, self.y - other.y)

	def __pow__(self, other):
		return self.x * other.x + self.y * other.y

	def __mod__(self, other):
		return self.x * other.y - self.y * other.x

	def __mul__(self, other):
		return vector(self.x * other, self.y * other)

	def manhattanLen(self):
		return abs(self.x) + abs(self.y)

	def rotate(self):
		return vector(self.y, -self.x)

	def normalize(self):
		if self.x == 0 and self.y == 0:
			return self
		else:
			return vector(self.x / self.len(), self.y / self.len())
(a, b, c) = map(int, input().split())
(x1, y1, x2, y2) = map(int, input().split())
A = vector(x1, y1)
B = vector(x2, y2)
if a == 0 or b == 0:
	print((A - B).manhattanLen())
	exit()
Ah = vector((-c - b * A.y) / a, A.y)
Av = vector(A.x, (-c - a * A.x) / b)
Bh = vector((-c - b * B.y) / a, B.y)
Bv = vector(B.x, (-c - a * B.x) / b)
print(min((A - B).manhattanLen(), (A - Ah).manhattanLen() + (Ah - Bh).len() + (Bh - B).manhattanLen(), (A - Ah).manhattanLen() + (Ah - Bv).len() + (Bv - B).manhattanLen(), (A - Av).manhattanLen() + (Av - Bh).len() + (Bh - B).manhattanLen(), (A - Av).manhattanLen() + (Av - Bv).len() + (Bv - B).manhattanLen()))


from math import sqrt

def ro(x, y):
	return sqrt((x[0] - y[0]) ** 2 + (x[1] - y[1]) ** 2)
(a, b, c) = list(map(int, input().split()))
A = [0, 0]
B = [0, 0]
(A[0], A[1], B[0], B[1]) = list(map(int, input().split()))
if a == 0 or b == 0:
	print(float(abs(A[0] - B[0]) + abs(A[1] - B[1])))
elif (-a * A[0] - c) / b > max(A[1], B[1]) and (-a * B[0] - c) / b > max(A[1], B[1]) or ((-a * A[0] - c) / b < min(A[1], B[1]) and (-a * B[0] - c) / b < min(A[1], B[1])):
	print(float(abs(A[0] - B[0]) + abs(A[1] - B[1])))
elif (B[0] - A[0]) / (B[1] - A[1]) * (-a / b) <= 0:
	print(float(abs(A[0] - B[0]) + abs(A[1] - B[1])))
else:
	ab = False
	bb = False
	cb = False
	db = False
	C = [0, 0]
	D = [0, 0]
	if min(A[1], B[1]) <= (-a * min(A[0], B[0]) - c) / b <= max(A[1], B[1]):
		ab = True
	if min(A[1], B[1]) <= (-a * max(A[0], B[0]) - c) / b <= max(A[1], B[1]):
		cb = True
	if min(A[0], B[0]) < (-b * max(A[1], B[1]) - c) / a < max(A[0], B[0]):
		bb = True
	if min(A[0], B[0]) < (-b * min(A[1], B[1]) - c) / a < max(A[0], B[0]):
		db = True
	k = -a / b
	r = abs(A[0] - B[0]) + abs(A[1] - B[1])
	if ab and bb:
		C[0] = min(A[0], B[0])
		C[1] = (-a * min(A[0], B[0]) - c) / b
		D[0] = (-b * max(A[1], B[1]) - c) / a
		D[1] = max(A[1], B[1])
		r = abs(C[1] - min(A[1], B[1])) + abs(max(A[0], B[0]) - D[0]) + ro(C, D)
	if ab and cb:
		C[0] = min(A[0], B[0])
		C[1] = (-a * min(A[0], B[0]) - c) / b
		D[0] = max(A[0], B[0])
		D[1] = (-a * max(A[0], B[0]) - c) / b
		if C[1] < D[1]:
			r = abs(C[1] - min(A[1], B[1])) + abs(max(A[1], B[1]) - D[1]) + ro(C, D)
		else:
			r = abs(D[1] - min(A[1], B[1])) + abs(max(A[1], B[1]) - C[1]) + ro(C, D)
	if ab and db:
		C[0] = min(A[0], B[0])
		C[1] = (-a * min(A[0], B[0]) - c) / b
		D[0] = (-b * min(A[1], B[1]) - c) / a
		D[1] = min(A[1], B[1])
		r = abs(max(A[1], B[1]) - C[1]) + abs(max(A[0], B[0]) - D[0]) + ro(C, D)
	if bb and cb:
		C[0] = (-b * max(A[1], B[1]) - c) / a
		C[1] = max(A[1], B[1])
		D[0] = max(A[0], B[0])
		D[1] = (-a * max(A[0], B[0]) - c) / b
		r = abs(C[0] - min(A[0], B[0])) + abs(D[1] - min(A[1], B[1])) + ro(C, D)
	if bb and db:
		C[0] = (-b * max(A[1], B[1]) - c) / a
		C[1] = max(A[1], B[1])
		D[0] = (-b * min(A[1], B[1]) - c) / a
		D[1] = min(A[1], B[1])
		if C[0] > D[0]:
			r = abs(D[0] - min(A[0], B[0])) + abs(max(A[0], B[0]) - C[0]) + ro(C, D)
		else:
			r = abs(C[0] - min(A[0], B[0])) + abs(max(A[0], B[0]) - D[0]) + ro(C, D)
	if cb and db:
		C[0] = max(A[0], B[0])
		C[1] = (-a * max(A[0], B[0]) - c) / b
		D[0] = (-b * min(A[1], B[1]) - c) / a
		D[1] = min(A[1], B[1])
		r = abs(D[0] - min(A[0], B[0])) + abs(max(A[1], B[1]) - C[1]) + ro(C, D)
	print(r)


from math import *
(a, b, c) = list(map(int, input().split()))
(x1, y1, x2, y2) = list(map(int, input().split()))
d = abs(x1 - x2) + abs(y1 - y2)
if a != 0 and b != 0:
	dy1 = abs(x1 + (c + b * y1) / a)
	dx1 = abs(y1 + (c + a * x1) / b)
	yy1 = y1
	xy1 = -(c + b * y1) / a
	xx1 = x1
	yx1 = -(c + a * x1) / b
	dy2 = abs(x2 + (c + b * y2) / a)
	dx2 = abs(y2 + (c + a * x2) / b)
	yy2 = y2
	xy2 = -(c + b * y2) / a
	xx2 = x2
	yx2 = -(c + a * x2) / b
	d1 = dy1 + dy2 + sqrt((xy1 - xy2) ** 2 + (yy1 - yy2) ** 2)
	d2 = dx1 + dx2 + sqrt((xx1 - xx2) ** 2 + (yx1 - yx2) ** 2)
	d3 = dy1 + dx2 + sqrt((xy1 - xx2) ** 2 + (yy1 - yx2) ** 2)
	d4 = dx1 + dy2 + sqrt((xx1 - xy2) ** 2 + (yx1 - yy2) ** 2)
	print(min(d, d1, d2, d3, d4))
else:
	print(d)


(a, b, c) = map(int, input().split())
(x1, y1, x2, y2) = map(int, input().split())
ans0 = round(abs(x1 - x2) + abs(y1 - y2), 9)
if a * b == 0:
	print(ans0)
	raise SystemExit
x11 = (-c - b * y1) / a
y12 = (-c - a * x1) / b
x21 = (-c - b * y2) / a
y22 = (-c - a * x2) / b
ans1 = abs(x1 - x11) + abs(x21 - x2) + ((y2 - y1) ** 2 + (x21 - x11) ** 2) ** 0.5
ans2 = abs(y1 - y12) + abs(x21 - x2) + ((y2 - y12) ** 2 + (x21 - x1) ** 2) ** 0.5
ans3 = abs(y1 - y12) + abs(y2 - y22) + ((x1 - x2) ** 2 + (y12 - y22) ** 2) ** 0.5
ans4 = abs(x1 - x11) + abs(y22 - y2) + ((x11 - x2) ** 2 + (y1 - y22) ** 2) ** 0.5
ans0 = min(ans0, ans1, ans2, ans3, ans4)
print(round(ans0, 10))


from math import sqrt
(a, b, c) = list(map(float, input().split()))
(x1, y1, x2, y2) = list(map(float, input().split()))

def main():
	nonlocal a, b, c, x1, y1, x2, y2
	if b == 0 or a == 0:
		return abs(x1 - x2) + abs(y1 - y2)
	(AD, AC, DB, CB) = (False, False, False, False)
	y = lambda x0: -c / b - a / b * x0
	x = lambda y0: -c / a - b / a * y0
	r = lambda x1, y1, x2, y2: sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2)
	yes = lambda x1, x, x2: min(x1, x2) <= x and x <= max(x1, x2)
	if yes(y1, y(x1), y2) and yes(y1, y(x2), y2):
		e = abs(y(x1) - y1)
		f = abs(y(x2) - y2)
		g = r(x1, y(x1), x2, y(x2))
		return e + f + g
	if yes(y1, y(x1), y2) and yes(x1, x(y2), x2):
		e = abs(y(x1) - y1)
		f = abs(x(y2) - x2)
		g = r(x1, y(x1), x(y2), y2)
		return e + f + g
	if yes(x1, x(y1), x2) and yes(x1, x(y2), x2):
		e = abs(x(y1) - x1)
		f = abs(x(y2) - x2)
		g = r(x(y1), y1, x(y2), y2)
		return e + f + g
	if yes(x1, x(y1), x2) and yes(y1, y(x2), y2):
		e = abs(x(y1) - x1)
		f = abs(y(x2) - y2)
		g = r(x(y1), y1, x2, y(x2))
		return e + f + g
	return abs(x1 - x2) + abs(y1 - y2)
ans = main()
straight = abs(x1 - x2) + abs(y1 - y2)
print(min(ans, straight))


from math import sqrt

def dist(p1, p2):
	(xa, ya) = p1
	(xb, yb) = p2
	return sqrt((xa - xb) ** 2 + (ya - yb) ** 2)

def card_dist(p1, p2):
	(xa, ya) = p1
	(xb, yb) = p2
	return abs(xa - xb) + abs(ya - yb)
(a, b, c) = map(int, input().split())
(x1, y1, x2, y2) = map(int, input().split())
to_line1 = []
to_line2 = []
if b != 0:
	to_line1.append((x1, -(c + a * x1) / b))
	to_line2.append((x2, -(c + a * x2) / b))
if a != 0:
	to_line1.append((-(c + b * y1) / a, y1))
	to_line2.append((-(c + b * y2) / a, y2))
dists = []
dists.append(card_dist((x1, y1), (x2, y2)))
for p1 in to_line1:
	for p2 in to_line2:
		dists.append(card_dist((x1, y1), p1) + dist(p1, p2) + card_dist(p2, (x2, y2)))
print(min(dists))


def dst1(x1, x2, y1, y2):
	return abs(x1 - x2) + abs(y1 - y2)

def dst2(x1, x2, y1, y2):
	return ((x1 - x2) ** 2 + (y1 - y2) ** 2) ** 0.5

def getx(y):
	return (-b * y - c) / a

def gety(x):
	return (-a * x - c) / b
(a, b, c) = map(int, input().split())
(x1, y1, x2, y2) = map(int, input().split())

def sign(a):
	if a > 0:
		return 1
	elif a == 0:
		return 0
	else:
		return -1
if a == 0 or b == 0:
	print(dst1(x1, x2, y1, y2))
else:
	s1 = dst1(x1, x2, y1, y2)
	p1x = x1
	p1y = gety(p1x)
	p3y = y1
	p3x = getx(p3y)
	p2x = x2
	p2y = gety(p2x)
	p4y = y2
	p4x = getx(p4y)
	s = 0
	s += dst1(x1, p1x, y1, p1y)
	s += dst2(p1x, p2x, p1y, p2y)
	s += dst1(p2x, x2, p2y, y2)
	s2 = s
	s = 0
	s += dst1(x1, p3x, y1, p3y)
	s += dst2(p3x, p2x, p3y, p2y)
	s += dst1(p2x, x2, p2y, y2)
	s3 = s
	s = 0
	s += dst1(x1, p1x, y1, p1y)
	s += dst2(p1x, p4x, p1y, p4y)
	s += dst1(p4x, x2, p4y, y2)
	s4 = s
	s = 0
	s += dst1(x1, p3x, y1, p3y)
	s += dst2(p3x, p4x, p3y, p4y)
	s += dst1(p4x, x2, p4y, y2)
	s5 = s
	print(min(s1, s2, s3, s4, s5))


(a, b, c) = list(map(int, input().split()))
(x1, y1, x2, y2) = list(map(int, input().split()))
if a == 0 or b == 0:
	print(abs(x1 - x2) + abs(y1 - y2))
else:
	a = a / -b
	c = c / -b
	if x1 <= x2 and y1 <= y2 or (x1 >= x2 and y1 >= y2):
		y1 = -y1
		y2 = -y2
		a = -a
		c = -c
		(x1, x2, y1, y2) = (min(x1, x2), max(x1, x2), max(y1, y2), min(y1, y2))
	ax = a
	bx = c
	ay = 1 / a
	by = -c / a
	ans = abs(x1 - x2) + abs(y1 - y2)
	Ax = ay * y1 + by
	Ay = ax * x1 + bx
	Bx = ay * y2 + by
	By = ax * x2 + bx
	ans = min(ans, abs(x1 - Ax) + abs(x2 - Bx) + ((Bx - Ax) ** 2 + (y1 - y2) ** 2) ** 0.5)
	ans = min(ans, abs(y1 - Ay) + abs(y2 - By) + ((By - Ay) ** 2 + (x1 - x2) ** 2) ** 0.5)
	ans = min(ans, abs(x1 - Ax) + abs(y2 - By) + ((x2 - Ax) ** 2 + (y1 - By) ** 2) ** 0.5)
	ans = min(ans, abs(x2 - Bx) + abs(Ay - y1) + ((Bx - x1) ** 2 + (Ay - y2) ** 2) ** 0.5)
	print(ans)


(a, b, c) = map(int, input().split())
(x1, y1, x2, y2) = map(int, input().split())
if a != 0 and b != 0:
	x1_ = -1 * (b * y1 + c) / a
	y1_ = -1 * (a * x1 + c) / b
	x2_ = -1 * (b * y2 + c) / a
	y2_ = -1 * (a * x2 + c) / b
	p1 = abs(x1 - x1_) + abs(y2 - y2_) + ((x1_ - x2) ** 2 + (y1 - y2_) ** 2) ** 0.5
	p2 = abs(x1 - x1_) + abs(x2 - x2_) + ((x1_ - x2_) ** 2 + (y1 - y2) ** 2) ** 0.5
	p3 = abs(y1 - y1_) + abs(y2 - y2_) + ((x1 - x2) ** 2 + (y1_ - y2_) ** 2) ** 0.5
	p4 = abs(y1 - y1_) + abs(x2 - x2_) + ((x1 - x2_) ** 2 + (y1_ - y2) ** 2) ** 0.5
	p5 = abs(y1 - y2) + abs(x2 - x1)
	sp = [p1, p2, p3, p4, p5]
	print(min(sp))
else:
	print(abs(y1 - y2) + abs(x2 - x1))


from math import sqrt

def ro(x, y):
	return sqrt((x[0] - y[0]) ** 2 + (x[1] - y[1]) ** 2)

def make_y(k):
	return (-a * k - c) / b

def make_x(k):
	return (-b * k - c) / a
(a, b, c) = list(map(int, input().split()))
A = [0, 0]
B = [0, 0]
(A[0], A[1], B[0], B[1]) = list(map(int, input().split()))
if a == 0 or b == 0:
	print(abs(A[0] - B[0]) + abs(A[1] - B[1]))
else:
	ans = [abs(A[0] - B[0]) + abs(A[1] - B[1]), abs(make_y(A[0]) - A[1]) + abs(make_y(B[0]) - B[1]) + ro([A[0], make_y(A[0])], [B[0], make_y(B[0])]), abs(make_x(A[1]) - A[0]) + abs(make_y(B[0]) - B[1]) + ro([make_x(A[1]), A[1]], [B[0], make_y(B[0])]), abs(make_y(A[0]) - A[1]) + abs(make_x(B[1]) - B[0]) + ro([A[0], make_y(A[0])], [make_x(B[1]), B[1]]), abs(make_x(A[1]) - A[0]) + abs(make_x(B[1]) - B[0]) + ro([make_x(A[1]), A[1]], [make_x(B[1]), B[1]])]
	print(min(ans))


(a, b, c) = map(int, input().split())
(x1, y1, x2, y2) = map(int, input().split())
ans = abs(x1 - x2) + abs(y1 - y2)
if a == 0 or b == 0:
	print(ans)
	exit(0)
s1 = (x1, (-c - a * x1) / b)
s2 = ((-c - b * y1) / a, y1)
f1 = (x2, (-c - a * x2) / b)
f2 = ((-c - b * y2) / a, y2)
a1 = abs(y1 - s1[1]) + min(((s1[0] - f1[0]) ** 2 + (s1[1] - f1[1]) ** 2) ** 0.5 + abs(y2 - f1[1]), ((s1[0] - f2[0]) ** 2 + (s1[1] - f2[1]) ** 2) ** 0.5 + abs(x2 - f2[0]))
a2 = abs(x1 - s2[0]) + min(((s2[0] - f1[0]) ** 2 + (s2[1] - f1[1]) ** 2) ** 0.5 + abs(y2 - f1[1]), ((s2[0] - f2[0]) ** 2 + (s2[1] - f2[1]) ** 2) ** 0.5 + abs(x2 - f2[0]))
print(min(ans, min(a1, a2)))


(a, b, c) = map(int, input().split())
(x1, y1, x2, y2) = map(int, input().split())
p = []
if b != 0:
	p.append((x1, -(a * x1 + c) / b))
	p.append((x2, -(a * x2 + c) / b))
if a != 0:
	p.append((-(b * y1 + c) / a, y1))
	p.append((-(b * y2 + c) / a, y2))
p2 = []
for (x, y) in p:
	if min(x1, x2) - 0.0001 < x < max(x1, x2) + 0.0001 and min(y1, y2) - 0.0001 < y < max(y1, y2) + 0.0001:
		p2.append((x, y))
p3 = []
for (x0, y0) in p2:
	for (x, y) in p3:
		if max(abs(x - x0), abs(y - y0)) < 0.0001:
			break
	else:
		p3.append((x0, y0))
if len(p3) < 2:
	print(abs(x1 - x2) + abs(y1 - y2))
else:
	r0 = abs(x1 - x2) + abs(y1 - y2)
	((ax, ay), (bx, by)) = p3
	d = ((ax - bx) ** 2 + (ay - by) ** 2) ** 0.5
	r1 = abs(x1 - ax) + abs(y1 - ay) + d + abs(bx - x2) + abs(by - y2)
	r2 = abs(x1 - bx) + abs(y1 - by) + d + abs(ax - x2) + abs(ay - y2)
	print(min(r0, r1, r2))


import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
import collections
from itertools import permutations
from collections import defaultdict
from collections import deque
import threading
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')

class SegmentTree:

	def __init__(self, data, default=-10 ** 6, func=lambda a, b: max(a, b)):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class SegmentTree1:

	def __init__(self, data, default=10 ** 6, func=lambda a, b: min(a, b)):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)
MOD = 10 ** 9 + 7

class Factorial:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorials = [1, 1]
		self.invModulos = [0, 1]
		self.invFactorial_ = [1, 1]

	def calc(self, n):
		if n <= -1:
			print('Invalid argument to calculate n!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.factorials):
			return self.factorials[n]
		nextArr = [0] * (n + 1 - len(self.factorials))
		initialI = len(self.factorials)
		prev = self.factorials[-1]
		m = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * i % m
		self.factorials += nextArr
		return self.factorials[n]

	def inv(self, n):
		if n <= -1:
			print('Invalid argument to calculate n^(-1)')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		p = self.MOD
		pi = n % p
		if pi < len(self.invModulos):
			return self.invModulos[pi]
		nextArr = [0] * (n + 1 - len(self.invModulos))
		initialI = len(self.invModulos)
		for i in range(initialI, min(p, n + 1)):
			next = -self.invModulos[p % i] * (p // i) % p
			self.invModulos.append(next)
		return self.invModulos[pi]

	def invFactorial(self, n):
		if n <= -1:
			print('Invalid argument to calculate (n^(-1))!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.invFactorial_):
			return self.invFactorial_[n]
		self.inv(n)
		nextArr = [0] * (n + 1 - len(self.invFactorial_))
		initialI = len(self.invFactorial_)
		prev = self.invFactorial_[-1]
		p = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * self.invModulos[i % p] % p
		self.invFactorial_ += nextArr
		return self.invFactorial_[n]

class Combination:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorial = Factorial(MOD)

	def ncr(self, n, k):
		if k < 0 or n < k:
			return 0
		k = min(k, n - k)
		f = self.factorial
		return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD
mod = 10 ** 9 + 7
omod = 998244353
prime = [True for i in range(200001)]
pp = [0] * 200001

def SieveOfEratosthenes(n=200000):
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
(a, b, c) = map(int, input().split())
(ax, ay, bx, by) = map(int, input().split())
if a == 0 or b == 0:
	print(abs(ax - bx) + abs(ay - by))
	exit()
oy = -(a * ax + c) / b
ty = -(a * bx + c) / b
ox = -(b * ay + c) / a
tx = -(b * by + c) / a
ans = abs(ax - bx) + abs(ay - by)
ans1 = abs(ay - oy) + abs(by - ty) + math.sqrt(abs(ax - bx) ** 2 + abs(oy - ty) ** 2)
ans2 = abs(ax - ox) + abs(bx - tx) + math.sqrt(abs(ay - by) ** 2 + abs(ox - tx) ** 2)
ans3 = abs(ax - ox) + abs(by - ty) + math.sqrt(abs(bx - ox) ** 2 + abs(ay - ty) ** 2)
ans4 = abs(ay - oy) + abs(bx - tx) + math.sqrt(abs(by - oy) ** 2 + abs(ax - tx) ** 2)
print(min(ans, ans1, ans2, ans3, ans4))


import math
(a, b, c) = [float(i) for i in input().split()]
xy = [float(i) for i in input().split()]
A = [xy[0], xy[1]]
B = [xy[2], xy[3]]
distances = []

def get_distance(K, M):
	return math.sqrt((K[0] - M[0]) * (K[0] - M[0]) + (K[1] - M[1]) * (K[1] - M[1]))

def get_point_h(K):
	x = (-b * K[1] - c) / a
	point = (x, K[1])
	distance = get_distance(K, point)
	return (point, distance)

def get_point_v(K):
	y = (-a * K[0] - c) / b
	point = (K[0], y)
	distance = get_distance(K, point)
	return (point, distance)
manhatten_distance = abs(A[0] - B[0]) + abs(A[1] - B[1])
distances.append(manhatten_distance)
if a != 0:
	(p1, d1) = get_point_h(A)
	(p3, d3) = get_point_h(B)
	distances.append(get_distance(p1, p3) + d1 + d3)
if b != 0:
	(p2, d2) = get_point_v(A)
	(p4, d4) = get_point_v(B)
	distances.append(get_distance(p2, p4) + d2 + d4)
if a != 0 and b != 0:
	distances.append(get_distance(p2, p3) + d2 + d3)
	distances.append(get_distance(p1, p4) + d1 + d4)
print(min(distances))


def length(x1, y1, x2, y2):
	return ((x1 - x2) ** 2 + (y1 - y2) ** 2) ** 0.5

def lengthhelp(xa, ya, xb, yb, xc, yc, xd, yd):
	return length(xa, ya, xb, yb) + length(xc, yc, xb, yb) + length(xc, yc, xd, yd)
(a, b, c) = map(int, input().split())
(x1, y1, x2, y2) = map(int, input().split())
if a == 0 or b == 0:
	print(abs(x1 - x2) + abs(y1 - y2))
	exit()
(p1x, p1y) = ((-c - b * y1) / a, y1)
(p2x, p2y) = (x1, (-c - a * x1) / b)
(p3x, p3y) = ((-c - b * y2) / a, y2)
(p4x, p4y) = (x2, (-c - a * x2) / b)
minim = min(lengthhelp(x1, y1, p1x, p1y, p3x, p3y, x2, y2), lengthhelp(x1, y1, p1x, p1y, p4x, p4y, x2, y2))
minim2 = min(lengthhelp(x1, y1, p2x, p2y, p3x, p3y, x2, y2), lengthhelp(x1, y1, p2x, p2y, p4x, p4y, x2, y2))
ans3 = abs(x1 - x2) + abs(y1 - y2)
print(min(min(minim, minim2), ans3))


from fractions import Fraction
from math import sqrt

def gety(a, b, c, x):
	return -Fraction(a * x + c, b)

def getx(a, b, c, y):
	return -Fraction(b * y + c, a)

def ds(x1, y1, x2, y2):
	return sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2)
(a, b, c) = list(map(int, input().split()))
(x1, y1, x2, y2) = list(map(int, input().split()))
silly_dist = abs(x1 - x2) + abs(y1 - y2)
if a == 0 or b == 0:
	print(silly_dist)
	return
dq = silly_dist
mx = x1
my = gety(a, b, c, mx)
ny = y1
nx = getx(a, b, c, ny)
kx = x2
ky = gety(a, b, c, kx)
ty = y2
tx = getx(a, b, c, ty)
dq1 = ds(mx, my, kx, ky) + ds(mx, my, x1, y1) + ds(kx, ky, x2, y2)
dq2 = ds(nx, ny, kx, ky) + ds(nx, ny, x1, y1) + ds(kx, ky, x2, y2)
dq3 = ds(mx, my, tx, ty) + ds(mx, my, x1, y1) + ds(tx, ty, x2, y2)
dq4 = ds(nx, ny, tx, ty) + ds(nx, ny, x1, y1) + ds(tx, ty, x2, y2)
dqmin = min([dq, dq1, dq2, dq3, dq4])
print(dqmin)


import math
s = input().split()
a = int(s[0])
b = int(s[1])
c = int(s[2])
s = input().split()
x1 = int(s[0])
y1 = int(s[1])
x2 = int(s[2])
y2 = int(s[3])
if x1 == x2:
	print(abs(y1 - y2))
elif y1 == y2:
	print(abs(x1 - x2))
elif a != 0 and b != 0:
	var1 = abs(x1 - x2) + abs(y1 - y2)
	var2 = 0
	x = x1
	y = (a * x + c) / b * -1
	var2 += abs(y1 - y)
	x3 = x2
	y3 = (a * x3 + c) / b * -1
	var2 += math.sqrt((x - x3) ** 2 + (y - y3) ** 2)
	var2 += abs(y3 - y2)
	var3 = 0
	x = x1
	y = (a * x + c) / b * -1
	var3 += abs(y1 - y)
	y3 = y2
	x3 = (b * y3 + c) / a * -1
	var3 += math.sqrt((x - x3) ** 2 + (y - y3) ** 2)
	var3 += abs(x3 - x2)
	var4 = 0
	y = y1
	x = (b * y + c) / a * -1
	var4 += abs(x1 - x)
	y3 = y2
	x3 = (b * y3 + c) / a * -1
	var4 += math.sqrt((x - x3) ** 2 + (y - y3) ** 2)
	var4 += abs(x3 - x2)
	var5 = 0
	y = y1
	x = (b * y + c) / a * -1
	var5 += abs(x1 - x)
	x3 = x2
	y3 = (a * x3 + c) / b * -1
	var5 += math.sqrt((x - x3) ** 2 + (y - y3) ** 2)
	var5 += abs(y3 - y2)
	print(min(var1, var2, var3, var4, var5))
else:
	print(abs(x1 - x2) + abs(y1 - y2))