#include #include const double eps = 0.000001; int main(){ double tf, td, vf, vd, hf, hd, t; scanf("%lf%lf%lf%lf%lf%lf", &tf, &vf, &hf, &td, &vd, &hd); //td = td - tf; //here td, tf from beggining // CASE FALLS BEFORE Td if(td * td > 2 * hf + eps){ t = sqrt(2*hf); printf("%f", td + 2 * vf * t / vd); return 0; } t = (vf * (td - tf)) / (vf - vd); // CASE FALLS AFTER Td, BEFORE DOG REACHES if(2*hf - t*t < eps || vd < vf){ t = sqrt(2*hf); printf("%f", td + 2 * vf * t / vd); return 0; } // CASE REACHES BENEATH Hd if(2*hf - t*t - hd < eps){ printf("%f", td + 2*t); return 0; } // CASE REACHES ABOVE Hd t = sqrt(2*(hf - hd)); double sp = t*vf; printf("%f", tf + t + sp/vd); return 0; }