Split the center points between the start points and the end points a and d.
Nothing else.
/* Three-Point question: for a given abcd four points (including speed and location), from a to d, find the shortest time. */# Include <stdio. h> # include <string. h> # include <stdlib. h> # include <math. h ># include <algorithm> using namespace std; const int maxn = 105; const double eps = 1e-8; const double pi = acos (-1.0); struct Point {double x, y ;}; Point a, B, c, d; double P, Q, R, ans1, ans2; double dis (Point aa, Point bb) {return sqrt (aa. x-bb.x) * (aa. x-bb.x) + (aa. y-bb.y) * (aa. y-bb.y);} double GetAns (double tt1, double tt2) {Double ans; Point temp1, temp2; temp1.x =. x + tt1 * (B. the x-a.x), temp1.y =. y + tt1 * (B. y-a.y); temp2.x = c. x + tt2 * (d. the x-c.x), temp2.y = c. y + tt2 * (d. y-c.y); ans = dis (a, temp1)/P + dis (temp1, temp2)/R + dis (temp2, d)/Q; return ans ;} double solve (double x) {double L, R, mid1, mid2; L = 0; R = 1; while (R-L> eps) {mid1 = (L + R) /2.0; mid2 = (mid1 + R)/2.0; if (GetAns (x, mid1) <GetAns (x, mid2) {ans2 = mid1; R = Mid2;} else {ans2 = mid2; L = mid1 ;}return GetAns (x, ans2) ;}int main () {int T; scanf ("% d ", & T); while (T --) {scanf ("% lf", &. x, &. y, & B. x, & B. y); scanf ("% lf", & c. x, & c. y, & d. x, & d. y); scanf ("% lf", & P, & Q, & R); double L, R, mid1, mid2; L = 0; R = 1; while (R-L> eps) {mid1 = (L + R)/2.0; mid2 = (mid1 + R)/2.0; if (solve (mid1) <solve (mid2) {ans1 = mid1; R = mid2;} else {ans1 = mi D2; L = mid1 ;}} printf ("%. 2lf \ n ", GetAns (ans1, ans2);} return 0;}/* three points: given four abcd points (including speed and position ), calculate the shortest time from a to d. */# Include <stdio. h> # include <string. h> # include <stdlib. h> # include <math. h ># include <algorithm> using namespace std; const int maxn = 105; const double eps = 1e-8; const double pi = acos (-1.0); struct Point {double x, y ;}; Point a, B, c, d; double P, Q, R, ans1, ans2; double dis (Point aa, Point bb) {return sqrt (aa. x-bb.x) * (aa. x-bb.x) + (aa. y-bb.y) * (aa. y-bb.y);} double GetAns (double tt1, double tt2) {double ans; Point temp1, temp2; temp1.x =. x + tt1 * (B. the x-a.x), temp1.y =. y + tt1 * (B. y-a.y); temp2.x = c. x + tt2 * (d. the x-c.x), temp2.y = c. y + tt2 * (d. y-c.y); ans = dis (a, temp1)/P + dis (temp1, temp2)/R + dis (temp2, d)/Q; return ans ;} double solve (double x) {double L, R, mid1, mid2; L = 0; R = 1; while (R-L> eps) {mid1 = (L + R) /2.0; mid2 = (mid1 + R)/2.0; if (GetAns (x, mid1) <GetAns (x, mid2) {ans2 = mid1; R = mid2 ;} else {ans2 = mid2; L = mid1 ;}return GetAns (x, ans2) ;}int main () {int T; scanf ("% d", & T ); while (T --) {scanf ("% lf", &. x, &. y, & B. x, & B. y); scanf ("% lf", & c. x, & c. y, & d. x, & d. y); scanf ("% lf", & P, & Q, & R); double L, R, mid1, mid2; L = 0; R = 1; while (R-L> eps) {mid1 = (L + R)/2.0; mid2 = (mid1 + R)/2.0; if (solve (mid1) <solve (mid2) {ans1 = mid1; R = mid2;} else {ans1 = mid2; L = mid1 ;}} printf ("%. 2lf \ n ", GetAns (ans1, ans2);} return 0 ;}