#include #include double px(double a1, double b1, double a2, double b2) { return (b2 - b1) / (a1 - a2); } double py(double a1, double b1, double a2, double b2) { return a1 * px(a1, b1, a2, b2) + b1; } int main() { double vl, vr, d, w; scanf("%lf %lf %lf %lf", &vl, &vr, &d, &w); double x1, y1, x2, y2, x3, y3; double tmp, ans = 0.0, tmpd; int flag = 0; x1 = y1 = 0; x2 = px(1 / w, 0, -(1 / vr), d / vr); y2 = py(1 / w, 0, -(1 / vr), d / vr); do { tmp = sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2)); ans += tmp; if (flag) { x3 = px(-(1 / vr), d / vr, 1 / w, y2 - 1 / w * x2); y3 = py(-(1 / vr), d / vr, 1 / w, y2 - 1 / w * x2); } else { x3 = px(1 / vl, 0, -(1 / w), y2 + 1 / w * x2); y3 = py(1 / vl, 0, -(1 / w), y2 + 1 / w * x2); } x1 = x2; x2 = x3; y1 = y2; y2 = y3; tmpd = x2 - x1 > 0 ? x2 - x1 : x1 - x2; flag = !flag; } while (tmpd > 10e-8); printf("%.7lf\n", ans); return 0; }