package main import ( "fmt" "math" ) func main() { ax, ay, bx, by := 0.0, 0.0, 0.0, 0.0 fmt.Scan(&ax, &ay, &bx, &by) left := min(ay, by) right := max(ay, by) for i := 0 ; i < 500 ; i++ { m1 := (left * 2.0 + right) / 3.0 m2 := (left + right * 2.0) / 3.0 c1 := compute(m1, ax, ay, bx, by) c2 := compute(m2, ax, ay, bx, by) if c1 < c2 { right = m2 } else { left = m1 } } fmt.Printf("%.9f\n", (left+right)/2) } func compute(my, ax, ay, bx, by float64) float64 { return math.Sqrt(ax*ax+(ay-my)*(ay-my)) + math.Sqrt(bx*bx+(by-my)*(by-my)) } func max(a, b float64) float64 { if a < b { return b } else { return a } } func min(a, b float64) float64 { if a > b { return b } else { return a } }