Search (three points): HDU 3400 Line Belt

Source: Internet
Author: User

Line Belt

Time limit:2000/1000 MS (java/others) Memory limit:32768/32768 K (java/others)
Total submission (s): 3531 Accepted Submission (s): 1364


problem DescriptionIn a two-dimensional plane there be-line belts, there be-segments AB and CD, LXHGWW's speed on AB's P and on CD IS-Q, he can move with the speed R on the plane.
How long must he take to travel from A to D?

InputThe first line was the case number T.
For each case, there is three lines.
The first line, four integers, the coordinates of A and B:ax Ay Bx by.
The second line, four integers, the coordinates of C and d:cx Cy Dx Dy.
The third line, three integers, P Q R.
0<= ax,ay,bx,by,cx,cy,dx,dy<=1000
1<=p,q,r<=10

OutputThe minimum time to travel from A to D, round to both decimals.

Sample Input10 0 0 100100 0 100 1002 2 1

Sample Output136.60
1 //rp++2 //#include <bits/stdc++.h>3 4#include <iostream>5#include <cstring>6#include <cstdio>7#include <cmath>8 9 using namespacestd;Ten  One Doubleeps=1e-8; A  - DoubleAx,ay,bx,by,cx,cy,dx,dy,p,q,r; -  the DoubleDIS (DoubleX1,DoubleY1,DoubleX2,Doubley2) - { -     returnsqrt ((x1-x2) * (X1-X2) + (y1-y2) * (y1-y2)); - } +  -  + DoubleGet_time (DoubleP1,Doublep2) A { at     returnDIS (ax,ay,ax+p1* (Bx-ax), ay+p1* (By-ay)) *1.0/p+dis (dx,dy,dx+p2* (CX-DX), dy+p2* (Cy-dy)) *1.0/q+ -DIS (bx+ (1.0-P1) * (AX-BX), by+ (1.0-P1) * (ay-by), cx+ (1.0-P2) * (DX-CX), cy+ (1.0-P2) * (dy-cy)) *1.0/R; - } -  - DoubleGet_min (DoublePOS) - { in     DoubleL=0.0, r=1.0, X,y,ret; -      while(r-l>=EPS) to     { +X= (r+2*L)/3.0; -Y= (2*R+L)/3.0; the          *x=Get_time (pos,x); $y=Get_time (pos,y);Panax Notoginseng          -          the         if(x-y>=eps) L= (r+2*L)/3.0; +         ElseR= (2*R+L)/3.0; A          theret=min (x, y); +     } -     returnret; $ } $  - DoubleSolve () - { the     DoubleL=0.0, r=1.0, X,y,ret; -      while(r-l>=EPS)Wuyi     { theX= (2*L+R)/3.0; -y= (L +2*R)/3.0; Wu          -x=get_min (x); Abouty=get_min (y); $          -          -         if(x-y>=eps) L= (2*L+R)/3.0; -         ElseR= (L +2*R)/3.0; A          +ret=min (x, y); the     } -     returnret; $ } the  the intMain () the { the     intT; -scanf"%d",&T); in      while(t--) the     { thescanf"%LF%LF%LF%LF",&ax,&ay,&bx,&by ); Aboutscanf"%LF%LF%LF%LF",&cx,&cy,&dx,&Dy); thescanf"%LF%LF%LF",&p,&q,&R); the          theprintf"%.2lf\n", Solve ()); +     } -     return 0; the}

Search (three points): HDU 3400 Line Belt

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.