Bzoj 1857 Conveyor Belt (three-part set of three points)

Source: Internet
Author: User

There are 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
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 row is 3 integers, respectively p,q,r
Output
The output data is a row, indicating the shortest time lxhgww from point A to point D, reserved to 2 digits after the decimal point.

It is obvious to start at some point E of AB and then go through the plane to a point F of the CD and then from F to D.
We assume that E has been determined, and then we determine the CD's F, we intuitively perceive that as the point F moves from C to D
The function image of time about displacement is a graph that is reduced first and then added.
Let's make sure E, through intuition,
The function image of the time about the displacement is still a graph that decreases first and then increases.
So we're going to start with three points, E, and F,
We solved the problem with a three-point set of three points.

# include <stdio.h># include<string.h># include<stdlib.h># include<iostream># include<vector># include<queue># include<stack># include<map># include<math.h># include<algorithm>using namespacestd;# define Lowbit (x) ( x)& (-x)) # define PI ACOs (-1.0) # define MAXN250005# define EPS 1e-3# define MAXM1000005# define MOD1000000007# define INF1000000000# define MEM (A, B) memset (A, B,sizeof(a) # define for (I,a,n) for(intI=a; i<=n; ++i) # define FO (I,a,n) for(intI=a; i<n; ++i) # define bug puts ("H"); # define LCH P<<1, l,mid# define RCH p<<1|1, mid+1, r# pragma comment (linker,"/stack:1024000000,1024000000") typedefLong Longll;typedef unsignedLong LongULL;int_max (intAintb) {returnA>b?a:b;}int_min (intAintb) {returnA>b?b:a;}intScan () {intres=0, flag=0; Charch; if((Ch=getchar ()) = ='-') flag=1; Else if(ch>='0'&&ch<='9') res=ch-'0';  while((Ch=getchar ()) >='0'&&ch<='9') res=res*Ten+ (ch-'0'); returnflag?-res:res;}voidOut (inta) {if(a<0) {Putchar ('-'); a=-A;} if(a>=Ten) Out (A/Ten); Putchar (A%Ten+'0');}Doubleax, Ay, BX, by, CX, CY, DX, DY, p, q, R;DoubleDisDoubleX1,DoubleY1,DoubleX2,Doubley2) {    returnsqrt ((x2-x1) * (x2-x1) + (y2-y1) * (y2-y1));}DoubleCalDoubleXDoubley) {    DoubleAns=dis (ax,ay,x,y)/p; DoubleLX=CX, Ly=cy, RX=DX, ry=dy;  while(Dis (lx,ly,rx,ry) >EPS) {        Doublep1x= (LX+LX+RX)/3, p1y= (Ly+ly+ry)/3, p2x= (LX+RX+RX)/3, p2y= (Ly+ry+ry)/3; DoubleT1=dis (P1x,p1y,dx,dy)/q+dis (x,y,p1x,p1y)/R, T2=dis (P2x,p2y,dx,dy)/q+dis (X,Y,P2X,P2Y)/R; if(T1&LT;=T2) RX=P2X, ry=p2y; ElseLX=P1X, ly=p1y; }    returnAns+dis (Lx,ly,dx,dy)/q+dis (x,y,lx,ly)/R;}intMain () {scanf ("%LF%LF%LF%LF%LF%LF%LF%LF%LF%LF%LF",&ax,&ay,&bx,&by,&cx,&cy,&dx,&dy,&p,&q,&R); DoubleLx=ax, Ly=ay, RX=BX, ry=by ;  while(Dis (lx,ly,rx,ry) >EPS) {        Doublep1x= (LX+LX+RX)/3, p1y= (Ly+ly+ry)/3, p2x= (LX+RX+RX)/3, p2y= (Ly+ry+ry)/3; DoubleT1=cal (p1x,p1y), t2=cal (P2X,P2Y); if(T1&LT;=T2) RX=P2X, ry=p2y; ElseLX=P1X, ly=p1y; } printf ("%.2lf\n", Cal (Lx,ly)); return 0;}
View Code

Bzoj 1857 Conveyor Belt (three-part set of three points)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.