#line 1 "main.cpp" #include #include #include using namespace std; using ldouble = long double; void solve() { ldouble x, y, z, d; cin >> x >> y >> z >> d; ldouble lt = z, gt = x / y; for (int q = 0; q < 100; ++q) { auto h = (lt + gt) / 2; auto w = x / h; auto bp = sqrt(h * h + y * y), bq = sqrt(w * w + z * z); if (bp > bq + d) { gt = h; } else { lt = h; } } auto h = lt; auto w = x / h; auto ans = x - (h * y + z * w + (h - z) * (w - y)) / 2; cout << ans << "\n"; } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10); solve(); return 0; }