// No.306 さいたま2008 // https://yukicoder.me/problems/no/306 // #include #include #include #include using namespace std; long double solve(long double ax, long double ay, long double bx, long double by); long double calc_dist(long double ax, long double ay, long double bx, long double by, long double py); int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); long double ax, ay, bx, by; cin >> ax >> ay >> bx >> by; long double ans = solve(ax, ay, bx, by); cout << fixed << setprecision(10) << ans << endl; } long double solve(long double ax, long double ay, long double bx, long double by) { long double uy = max(ay, by); long double ly = min(ay, by); for (auto i = 0; i < 100; ++i) { long double py1 = (ly * 2 + uy) / 3; long double mid1_dist = calc_dist(ax, ay, bx, by, py1); long double py2 = (ly + uy * 2) / 3; long double mid2_dist = calc_dist(ax, ay, bx, by, py2); if (mid2_dist > mid1_dist) uy = py2; else ly = py1; } return (uy + ly) / 2; } long double calc_dist(long double ax, long double ay, long double bx, long double by, long double py) { long double ap = sqrt((ax*ax + (ay-py)*(ay-py))); long double bp = sqrt((bx*bx + (by-py)*(by-py))); return ap + bp; }