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 Description
  In
a two-dimensional plane there are two line belts, there are two
segments AB and CD, lxhgww's speed on AB is P and on CD is Q, he can
move with the speed R on other area on the plane.
How long must he take to travel from A to D?
 
Input
The first line is the case number T.
For each case, there are 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
 
Output
The minimum time to travel from A to D, round to two decimals.
 
Sample Input
1
0 0 0 100
100 0 100 100
2 2 1
 
Sample Output
136.60
 
  

 //rp++
//#include <bits/stdc++.h> #include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath> using namespace std; double eps=1e-; double Ax,Ay,Bx,By,Cx,Cy,Dx,Dy,P,Q,R; double DIS(double x1,double y1,double x2,double y2)
{
return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
} double Get_Time(double p1,double p2)
{
return DIS(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;
} double Get_MIN(double pos)
{
double L=0.0,R=1.0,x,y,ret;
while(R-L>=eps)
{
x=(R+*L)/3.0;
y=(*R+L)/3.0; x=Get_Time(pos,x);
y=Get_Time(pos,y); if(x-y>=eps)L=(R+*L)/3.0;
else R=(*R+L)/3.0; ret=min(x,y);
}
return ret;
} double Solve()
{
double L=0.0,R=1.0,x,y,ret;
while(R-L>=eps)
{
x=(*L+R)/3.0;
y=(L+*R)/3.0; x=Get_MIN(x);
y=Get_MIN(y); if(x-y>=eps)L=(*L+R)/3.0;
else R=(L+*R)/3.0; ret=min(x,y);
}
return ret;
} int main()
{
int T;
scanf("%d",&T);
while(T--)
{
scanf("%lf%lf%lf%lf",&Ax,&Ay,&Bx,&By);
scanf("%lf%lf%lf%lf",&Cx,&Cy,&Dx,&Dy);
scanf("%lf%lf%lf",&P,&Q,&R); printf("%.2lf\n",Solve());
}
return ;
}

搜索(三分):HDU 3400 Line belt的更多相关文章

  1. 三分套三分 --- HDU 3400 Line belt

    Line belt Problem's Link:   http://acm.hdu.edu.cn/showproblem.php?pid=3400 Mean: 给出两条平行的线段AB, CD,然后一 ...

  2. HDU 3400 Line belt (三分再三分)

    HDU 3400 Line belt (三分再三分) ACM 题目地址:  pid=3400" target="_blank" style="color:rgb ...

  3. HDU 3400 Line belt (三分嵌套)

    题目链接 Line belt Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)To ...

  4. HDU 3400 Line belt (三分套三分)

    http://acm.split.hdu.edu.cn/showproblem.php?pid=3400 题意: 有两条带子ab和cd,在ab上的速度为p,在cd上的速度为q,在其它地方的速度为r.现 ...

  5. HDU 3400 Line belt【三分套三分】

    从A出发到D,必定有从AB某个点E出发,从某个点F进入CD 故有E,F两个不确定的值. 在AB上行走的时间   f = AE / p 在其他区域行走的时间 g = EF / r 在CD上行走的时间   ...

  6. hdu 3400 Line belt 三分法

    思路:要求最短时间从A到D,则走的路线一定是AB上的一段,CD上的一段,AB与CD之间的一段. 那么可以先三分得到AB上的一个点,在由这个点三分CD!! 代码如下: #include<iostr ...

  7. hdu 3400 Line belt

    题意:给你两条线段AB,CD:然后给你在AB,CD上的速度P,Q,在其它部分的速度是R,然后求A到D的最短时间. 思路:用三分枚举从AB线段上离开的点,然后再用三分枚举在CD的上的点找到最优点,求距离 ...

  8. 【HDOJ】3400 Line belt

    三分. #include <cstdio> #include <cstring> #include <cmath> typedef struct { double ...

  9. Line belt

    Problem Description In a two-dimensional plane there are two line belts, there are two segments AB a ...

随机推荐

  1. sqlite使用blob类型存储/访问 结构体

    /* open fire host and slora report data database */ int open_report_db(void) { ; char sql[SQL_COMMAN ...

  2. 【转】Angularjs Controller 间通信机制

    在Angularjs开发一些经验总结随笔中提到我们需要按照业务却分angular controller,避免过大无所不能的上帝controller,我们把controller分离开了,但是有时候我们需 ...

  3. iBatis 的条件查询

    之类以传入ID进行举例 Student.xml 在里面设置一个ID的标志位,设置类型 <select id="selectAllStudentByid" parameterC ...

  4. winform(C#)拖拽实现获得文件路径

    设置Form的AllowDrop为true  private void Form1_DragDrop(object sender, DragEventArgs e)        {          ...

  5. removing right click context menu options on recycle bin

    Humpty is correct as always  First you might want to make a backup of the reg key then remove the Wa ...

  6. AspNet WebApi: 了解下HttpControllerDispatcher,控制器的创建和执行

    HttpControllerDispatcher作为ASPNET WEB API消息处理管道中重要的部分,负责最后控制器系统的激活,action方法的执行,以及最后的响应生成. HtppControl ...

  7. YII 小部件实现Area textArea

    <?php echo $form->textArea($user_model,'introduce',array('cols'=>50,'rows'=>5)); ?>

  8. TatukGIS-TGIS_ShapeArc.GetPointOnLine

    function GetPointOnLine(const _distance: Double; const _offset: Double; const _part: Integer): TGIS_ ...

  9. 转:php使用websocket示例详解

    原文来自于:http://www.jb51.net/article/48019.htm 这篇文章主要介绍了php使用websocket示例,需要的朋友可以参考下   下面我画了一个图演示 client ...

  10. [POJ 2774] Long Long Message 【后缀数组】

    题目链接:POJ - 2774 题目分析 题目要求求出两个字符串的最长公共子串,使用后缀数组求解会十分容易. 将两个字符串用特殊字符隔开再连接到一起,求出后缀数组. 可以看出,最长公共子串就是两个字符 ...