The main topic: give the plane on the two line segment, in the two segments walk has a certain speed, on the other plane walk also has a certain speed, ask from a point to D point at least how much time required.
Thought: It seems that three points, probably feel it, anyway, will not be proven.
CODE:
#include <cmath> #include <cstdio> #include <iomanip> #include <cstring> #include <iostream > #include <algorithm> #define EPS 1e-7#define INF 1e15using namespace std;struct point{double x, y; Point (Double _,double __): X (_), Y (__) {}point () {}void Read () {scanf ("%lf%lf", &x,&y);} Point operator + (const-point-&a) const {return point (x + a.x,y + a.y);} Point operator-(const point &a) const {return point (X-A.X,Y-A.Y);} Point operator * (double A) const {return point (x * a,y * a);} Point operator/(double a) const {return point (x/a,y/a);}} A,b,c,d;inline Double Calc (const point &a,const point &b) {return sqrt ((a.x-b.x) * (a.x-b.x) + (A.Y-B.Y) * (A . y-b.y));} Double v1,v2,v3;double tridivide (const point &p,point l,point R) {When (Calc (l,r) > EPS) {point u = (r-l)/3.0; Point P1 = l + u,p2 = p1 + u;double ans1 = Calc (a,p)/v1 + calc (p1,d)/v2 + calc (p,p1)/v3;double ans2 = Calc (a,p)/v1 + Calc (p2,d)/v2 + calc (p,p2)/V3;if (anS1 > Ans2) L = P1;elser = p2;} Return Calc (a,p)/v1 + calc (l,d)/v2 + calc (p,l)/v3;} Double Tridivide (Point L,point R) {When (Calc (l,r) > EPS) {point u = (r-l)/3.0; Point P1 = l + u,p2 = p1 + u;double ans1 = Tridivide (p1,c,d), ans2 = Tridivide (p2,c,d), if (Ans1 > Ans2) L = P1;elser = P2; }return tridivide (l,c,d);} int main () {A.read (), B.read (), C.read (), D.read (); scanf ("%lf%lf%lf", &v1,&v2,&v3); cout << Fixed < < Setprecision (2) << tridivide (A, b) << Endl;return 0;}
Bzoj 1857 scoi 2010 Conveyor Belt Three-part method