← Home
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

type Node struct {
	x, y, d float64
}

func main() {
	in := bufio.NewReader(os.Stdin)
	var a, b, c float64
	var x1, y1, x2, y2 float64
	if _, err := fmt.Fscan(in, &a, &b, &c); err != nil {
		return
	}
	fmt.Fscan(in, &x1, &y1, &x2, &y2)

	ans := math.Abs(x1-x2) + math.Abs(y1-y2)

	var A, Bc []Node
	if a != 0 {
		xh1 := (-b*y1 - c) / a
		A = append(A, Node{xh1, y1, math.Abs(xh1 - x1)})
		xh2 := (-b*y2 - c) / a
		Bc = append(Bc, Node{xh2, y2, math.Abs(xh2 - x2)})
	}
	if b != 0 {
		yv1 := (-a*x1 - c) / b
		A = append(A, Node{x1, yv1, math.Abs(yv1 - y1)})
		yv2 := (-a*x2 - c) / b
		Bc = append(Bc, Node{x2, yv2, math.Abs(yv2 - y2)})
	}

	for _, p := range A {
		for _, q := range Bc {
			d := p.d + q.d + math.Hypot(p.x-q.x, p.y-q.y)
			if d < ans {
				ans = d
			}
		}
	}

	out := bufio.NewWriter(os.Stdout)
	fmt.Fprintf(out, "%.10f\n", ans)
	out.Flush()
}