搜索(三分):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 ...
随机推荐
- day-10
/* 还是习惯在插入里面写东西 233 今晚停电了 一屋人唱歌讲鬼故事 挺开心的 还有不到十天大家就要分开了 还记得第一次来机房的时候 大家都还不认识 到现在快一年了 大家可以一起闹一起笑 一起没心没 ...
- StructureMap Exception Code: 207 Internal exception while creating Instance '06fc8bd7-76db-47c1-8d71-31090a074f5e' of PluginType QIMS.Repository.IComStaffRepository. Check the inner exception for more
标题翻译: StructureMap异常代码:207内部异常,同时创造PluginType QIMS.Repository.IComStaffRepository的实例“06fc8bd7-76db-4 ...
- HTML5表单提交和PHP环境搭建
HTML5表单提交相关内容和PHP环境搭建需要的软件(只备注) (2)举例介绍 (3)PHP环境搭建
- 内存储与外存储(IO流的应用)
存储分为内存储,外存储(Sd卡存储),其中还涉及IO流的应用. 我们先来看内存储,在布局中EditView中输入的内容,通过点击按钮,分别进行保存,读取,删除的操作,读取时显示在下面的TextView ...
- asp.net mvc生命周期学习
ASP.NET MVC是一个扩展性非常强的框架,探究其生命周期对用Mock框架来模拟某些东西,达到单元测试效果,和开发扩展我们的程序是很好的. 生命周期1:创建routetable.把URL映射到ha ...
- IIS 64位上發佈32位asp.net設置
錯誤:無法載入檔案或組件 'Maticsoft.Web' 或其相依性的其中之一. 試圖載入格式錯誤的程式. 解決:新增應用程序池——高級設置——啟用32位應用程式——True
- java 更改list 某一元素?
if(!elTd.getElementsByTag("p").isEmpty()){ int i=eduList.size(); if(i>0){ ...
- ios8及以前的特性
目前最新系统为ios8.以下为历代系统的回顾: iOS 1 关键词:iPhone的诞生 也许放在现在来看,当时的情景很难想象.当第一代iPhone正式发布时,在某些功能和方面其实是要远远落后于当时的竞 ...
- weChat聊天发送图片带有小尖角的实现
weChat聊天发送图片带有小尖角的实现 1.#import <UIKit/UIKit.h>2.3.@interface JKShapeImage : UIView4.5.@propert ...
- block 浅析
最近讲了一个关于block的例子 block 可以作为一个参数 进行传递 需要注意的地方是 :block 虽然作为一个参数 但是在函数方法执行的时候 block 是不会在定义它的地方调用 除非你在后边 ...