搜索(三分):HDU 3400 Line belt
Line belt
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 3531 Accepted Submission(s): 1364
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?
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
0 0 0 100
100 0 100 100
2 2 1
//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的更多相关文章
- 三分套三分 --- HDU 3400 Line belt
Line belt Problem's Link: http://acm.hdu.edu.cn/showproblem.php?pid=3400 Mean: 给出两条平行的线段AB, CD,然后一 ...
- HDU 3400 Line belt (三分再三分)
HDU 3400 Line belt (三分再三分) ACM 题目地址: pid=3400" target="_blank" style="color:rgb ...
- HDU 3400 Line belt (三分嵌套)
题目链接 Line belt Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)To ...
- HDU 3400 Line belt (三分套三分)
http://acm.split.hdu.edu.cn/showproblem.php?pid=3400 题意: 有两条带子ab和cd,在ab上的速度为p,在cd上的速度为q,在其它地方的速度为r.现 ...
- HDU 3400 Line belt【三分套三分】
从A出发到D,必定有从AB某个点E出发,从某个点F进入CD 故有E,F两个不确定的值. 在AB上行走的时间 f = AE / p 在其他区域行走的时间 g = EF / r 在CD上行走的时间 ...
- hdu 3400 Line belt 三分法
思路:要求最短时间从A到D,则走的路线一定是AB上的一段,CD上的一段,AB与CD之间的一段. 那么可以先三分得到AB上的一个点,在由这个点三分CD!! 代码如下: #include<iostr ...
- hdu 3400 Line belt
题意:给你两条线段AB,CD:然后给你在AB,CD上的速度P,Q,在其它部分的速度是R,然后求A到D的最短时间. 思路:用三分枚举从AB线段上离开的点,然后再用三分枚举在CD的上的点找到最优点,求距离 ...
- 【HDOJ】3400 Line belt
三分. #include <cstdio> #include <cstring> #include <cmath> typedef struct { double ...
- Line belt
Problem Description In a two-dimensional plane there are two line belts, there are two segments AB a ...
随机推荐
- Initializer block.
Ref: Initializing Fields Instance initializers are permitted to refer to the current object via the ...
- 表单提交对chrome记住密码的影响
在处理注册.登录等含有用户名,密码的元素的表单时,chrome会主动的提示记住密码,然而这个功能在用户名的选择上真是耐人寻味,它总是寻找离password input控件最近的那一个文本框的内容,作为 ...
- Android TV 模拟器启动
模拟器启动错误 使用IntelCPU的模拟器 http://software.intel.com/en-us/android/articles/intel-hardware-accelerated-e ...
- zoj 3209.Treasure Map(DLX精确覆盖)
直接精确覆盖 开始逐行添加超时了,换成了单点添加 #include <iostream> #include <cstring> #include <cstdio> ...
- 【BZOJ1012】【树状数组求区间最值】最大数maxnumber
Description 现在请求你维护一个数列,要求提供以下两种操作: 1. 查询操作.语法:Q L 功能:查询当前数列中末尾L个数中的最大的数,并输出这个数的值.限制:L不超过当前数列的长度. 2. ...
- iOS图片的伪裁剪(改变图片的像素值)
0x00 原理 利用一张图片事先画好的图片(以下称为蒙板),盖在要被裁剪的的图片上,然后遍历蒙板上的像素点,修改被裁剪图片对应位置的像素的色值即可得到一些我们想要的不规则图片了(比如人脸) 0x01 ...
- linux之uniq
Linux命令uniq的作用是过滤重复部分显示文件内容,这个命令读取输入文件,并比较相邻的行.在正常情况下,第二个及以后更多个重复行将被删去,行 比较是根据所用字符集的排序序列进行的.该命令加工后的结 ...
- 写个自己的Xcode4插件
推荐:http://onevcat.com/2013/02/xcode-plugin/ 刚写iOS程序的时候就知道Xcode支持第三方插件,比如ColorSense等很实用的插件,但Xcode的插 ...
- Java高阶面试问题合集
下面总结一下在Java面试中常用的一些问题,不具体解答,我只附上一些精彩的博文链接. Spring IOC AOP 底层原理 JAVA的反射机制和动态代理 Java反射机制和动态代理 多线程 Spri ...
- Adobe Acrobat XI Pro 两种破解方式 Keygen秘钥 license替换 亲测有效
大家平时看paper比较多的话想必都是用Adobe Acrobat而非Adobe Reader吧,其功能全面之处就不啰嗦了,下面给大家分享下Adobe Acrobat XI Pro的两种破解方式(两种 ...