// tested by Hightail - https://github.com/dj3500/hightail import std.stdio, std.string, std.conv, std.algorithm; import std.range, std.array, std.math, std.typecons, std.container, core.bitop; immutable inf = 10^^9 + 7; int xa, ya; int xb, yb; void main() { scan(xa, ya); scan(xb, yb); if (ya == yb) { writeln(ya); return; } double top, btm; if (ya > yb) { swap(xa, xb); swap(ya, yb); } top = yb; btm = ya; foreach (i ; 0 .. 1000) { double m1 = btm + (top - btm) / 3; double m2 = btm + (top - btm) * 2 / 3; debug { writeln(m1, " ", m2); } double d1 = sqrt(xa^^2 + (m1 - ya)^^2) + sqrt(xb^^2 + (yb - m1)^^2); double d2 = sqrt(xa^^2 + (m2 - ya)^^2) + sqrt(xb^^2 + (yb - m2)^^2); if (d1 < d2) { top = m2; } else { btm = m1; } } writefln("%.10f", btm); } void scan(T...)(ref T args) { string[] line = readln.split; foreach (ref arg; args) { arg = line.front.to!(typeof(arg)); line.popFront(); } assert(line.empty); }