import java.util.Scanner; import java.util.function.DoubleUnaryOperator; import java.lang.Math; /** * @Problems https://yukicoder.me/problems/no/306 */ public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); double x1 = sc.nextDouble(), y1 = sc.nextDouble(), x2 = sc.nextDouble(), y2 = sc.nextDouble(); Sanbun s = new Sanbun(0, 1000); s.setFunction(y -> { double sa1 = Math.abs(y - y1); double sa2 = Math.abs(y - y2); return Math.sqrt(x1 * x1 + sa1 * sa1) + Math.sqrt(x2 * x2 + sa2 * sa2); }); System.out.println(s.run()); } } class Sanbun { private double left, right; private DoubleUnaryOperator function; private double gosa = 1E-7; public Sanbun(double left, double right) { this.left = left; this.right = right; } public Sanbun(double left, double right, DoubleUnaryOperator function) { this(left, right); this.function = function; } private double calc(double value) { return function.applyAsDouble(value); } public void setFunction(DoubleUnaryOperator function) { this.function = function; } public double run() { while (right - left > gosa) { double midLeft = left + (right - left) / 3; double midRight = right - (right - left) / 3; double midLeftResult = calc(midLeft); double midRightResult = calc(midRight); if (midLeftResult > midRightResult) { left = midLeft; } else { right = midRight; } } return left; } }