Topic links
1857: [Scoi2010] Belt time limit:1 Sec Memory limit:64 MB
submit:934 solved:501
[Submit] [Status] [Discuss] The description has two conveyors on a 2-dimensional plane, each of which can be seen as a line segment. Two conveyor belts are segment AB and segment CD respectively. The movement speed of the LXHGWW on AB is P, the speed of movement on the CD is Q, and the moving speed on the plane is R. Now LXHGWW wants to go from point A to point D, he wants to know at least how long it takes. Input data the first line is 4 integers, representing the coordinates of a and B, respectively, ax,ay,bx,by the second row is 4 integers, representing the coordinates of C and D, respectively, Cx,cy,dx,dy The third line is 3 integers, p,q,routput output data is a row, indicating lxhgww from point A to D point of the shortest time, reserved to 2 digits after the decimal point sample Input0 0 0 100
100 0 100 100
2 2 1
Sample Output136.60
three points, three points, you can do it.
#include <iostream>#include<vector>#include<cstdio>#include<cstring>#include<algorithm>#include<cmath>#include<map>#include<Set>#include<string>#include<queue>#include<stack>#include<bitset>using namespacestd;#definePB (x) push_back (x)#definell Long Long#defineMK (x, y) make_pair (x, y)#defineLson L, M, rt<<1#defineMem (a) memset (a, 0, sizeof (a))#defineRson m+1, R, rt<<1|1#defineMem1 (a) memset (a,-1, sizeof (a))#defineMEM2 (a) memset (a, 0x3f, sizeof (a))#defineRep (i, N, a) for (int i = A; i<n; i++)#defineFi first#defineSe Secondtypedef pair<int,int>PLL;Const DoublePI = ACOs (-1.0);Const DoubleEPS = 1e-8;Const intMoD = 1e9+7;Const intINF =1061109567;Const intdir[][2] = { {-1,0}, {1,0}, {0, -1}, {0,1} };Doublexa, XB, xc, XD, ya, YB, YC, yd, p, q, R;DoubleDisDoubleX1,DoubleY1,DoubleX2,Doubley2) { returnsqrt ((x1-x2) * (X1-X2) + (y1-y2) * (y1-y2));}DoubleTernary (DoubleXDoubley) {DoubleLX = xc, ly = YC, rx = xd, ry =yd; while(Fabs (RX-LX) >eps | | fabs (ry-ly) >EPS) { DoubleX1 = lx+ (RX-LX)/3, x2 = lx+ (RX-LX)/3*2; DoubleY1 = ly+ (ry-ly)/3, y2 = ly+ (ry-ly)/3*2; DoubleTMP1 = Dis (x, y, x1, y1)/r+dis (x1, y1, XD, yd)/q+dis (x, y, xa, ya)/p; DoubleTMP2 = Dis (x, y, x2, y2)/r+dis (x2, y2, XD, yd)/q+dis (x, y, xa, ya)/p; if(tmp1>TMP2) {LX= x1, ly =Y1; } Else{Rx= x2, ry =Y2; } } returnDis (x, y, LX, ly)/r+dis (LX, LY, XD, yd)/q+dis (x, y, xa, ya)/p;}Doublesolve () {DoubleLX = xa, rx = xb, ly = ya, ry =YB; while(Fabs (RX-LX) >eps | | fabs (ry-ly) >EPS) { DoubleX1 = lx+ (RX-LX)/3, x2 = lx+ (RX-LX)/3*2; DoubleY1 = ly+ (ry-ly)/3, y2 = ly+ (ry-ly)/3*2; DoubleTMP1 = ternary (x1, y1), TMP2 =ternary (x2, y2); if(tmp1>TMP2) {LX= x1, ly =Y1; } Else{Rx= x2, ry =Y2; } } returnternary (LX, ly);}intMain () {CIN>>xa>>ya>>xb>>yb>>xc>>yc>>xd>>yd>>p>>q>>R; DoubleAns =solve (); printf ("%.2f\n", ans); return 0;}
Bzoj 1857: [Scoi2010] belt three points