hdoj 3400 三分
两次三分
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
int x[5],y[5],v[5]; double cal(double x1,double x2,double y1,double y2)
{
double tmp=(x1-x2)*(x1-x2);
tmp+=(y1-y2)*(y1-y2);
return sqrt(tmp);
} double chk(double xx,double yy)
{
double stx=x[3],sty=y[3],edx=x[4],edy=y[4];
double txt1,txt2;
while(1)
{
txt1=cal(xx,x[1],yy,y[1])/v[1]+cal(stx+(edx-stx)/3,x[4],sty+(edy-sty)/3,y[4])/v[2];
txt1+=cal(xx,stx+(edx-stx)/3,yy,sty+(edy-sty)/3)/v[3];
txt2=cal(xx,x[1],yy,y[1])/v[1]+cal(stx+(edx-stx)/3*2,x[4],sty+(edy-sty)/3*2,y[4])/v[2];
txt2+=cal(xx,stx+(edx-stx)/3*2,yy,sty+(edy-sty)/3*2)/v[3];
if(txt1<txt2)
{
edx=stx+(edx-stx)/3*2;
edy=sty+(edy-sty)/3*2;
}
else
{
stx=stx+(edx-stx)/3;
sty=sty+(edy-sty)/3;
}
if(fabs(txt1-txt2)<0.0001) break;
}
return txt1;
} int main()
{
int T;
scanf("%d",&T);
while(T--)
{
for(int i=1;i<=4;i++)
scanf("%d %d",&x[i],&y[i]);
for(int i=1;i<=3;i++)
scanf("%d",&v[i]);
double stx=x[1],sty=y[1],edx=x[2],edy=y[2];
double txt1,txt2;
while(1)
{
txt1=chk(stx+(edx-stx)/3,sty+(edy-sty)/3);
txt2=chk(stx+(edx-stx)/3*2,sty+(edy-sty)/3*2);
if(txt1<txt2)
{
edx=stx+(edx-stx)/3*2;
edy=sty+(edy-sty)/3*2;
}
else
{
stx=stx+(edx-stx)/3;
sty=sty+(edy-sty)/3;
}
if(fabs(txt1-txt2)<0.0001) break;
}
printf("%.2f\n",(txt1+txt2)/2);
}
return 0;
}
hdoj 3400 三分的更多相关文章
- hdu 2899 hdu 3400 三分/几何
hdu2899 : 水提,直接三分,事实上求导后二分也能够. #include<iostream> #include<cstdio> using namespace std; ...
- 三分套三分 --- 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 (三分套三分)
http://acm.split.hdu.edu.cn/showproblem.php?pid=3400 题意: 有两条带子ab和cd,在ab上的速度为p,在cd上的速度为q,在其它地方的速度为r.现 ...
- 三分 HDOJ 3714 Error Curves
题目传送门 /* 三分:凹(凸)函数求极值 */ #include <cstdio> #include <algorithm> #include <cstring> ...
- HDU 3400 Line belt (三分再三分)
HDU 3400 Line belt (三分再三分) ACM 题目地址: pid=3400" target="_blank" style="color:rgb ...
- HDU 3400 Line belt【三分套三分】
从A出发到D,必定有从AB某个点E出发,从某个点F进入CD 故有E,F两个不确定的值. 在AB上行走的时间 f = AE / p 在其他区域行走的时间 g = EF / r 在CD上行走的时间 ...
- [三分]HDOJ 5531 Rebuild
题意:给n个点,以这n个点为圆心画圆,使得所有的圆与其相邻的圆相切. 求n个圆最小的面积和. 分析:很容易想到确定了其中一个圆的半径之后,其他的圆的半径也能随之确定了. 画一画三个点的和四个点的,会发 ...
- 【HDOJ】3400 Line belt
三分. #include <cstdio> #include <cstring> #include <cmath> typedef struct { double ...
- HDU 3400 Line belt (三分嵌套)
题目链接 Line belt Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)To ...
随机推荐
- HDU 4588 Count The Carries 计算二进制进位总数
点击打开链接 Count The Carries Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65535/32768 K (Java ...
- OpenWrt sscanf问题之于MT7620N与AR9341
在MT7620N平台做好了wifidog的相关调试工作,除了eth驱动.wireless性能问题,其余的都能够基本正常. 依据实际须要要对已完毕的工作在AR9341平台上实现. 事实上也简单.基本功能 ...
- 使用Qt Style Sheets制作UI特效
引言 作为一套GUI框架,Qt是非常强大的.(注:Qt 不仅是一套优秀的GUI框架,同时也是一套出色的应用程序框架).在UI的制作方面Qt为广大开发者提供了一套强大而易用的工具,她就是——Qt Sty ...
- 【转】Objective-C消息机制的原理
转自:http://dangpu.sinaapp.com/?p=119 在Objective-C中,message与方法的真正实现是在执行阶段绑定的,而非编译阶段.编译器会将消息发送转换成对objc_ ...
- (转)关于font-size:100%
重设浏览器默认字体大小 h1,h2,h3,h4,h5,h6 {font-size:100%;font-weight:normal;} 假如你设置body{font-size:12px;} 但h1是不会 ...
- C# 参数按照ASCII码从小到大排序(字典序)
在对接第三方支付的时候,第三方会要求参数按照ASCII码从小到大排序.如下: public static void requestPay() { Dictionary<string, strin ...
- 定义了重复的system.web.extensions/scripting/scriptResourceHandler怎么办
今天移转系统,都配置好之后,系统报错说我的web服务下的web.config 定义了重复的 system.web.extensions/scripting/scriptResourceHandler ...
- BestCoder Round #81 (div.2)1001
Machine Accepts: 580 Submissions: 1890 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65 ...
- 使用注解@Transient使表中没有此字段
注意,实体类中要使用org.springframework.data.annotation.Transient 在写实体类时发现有加@Transient注解的 加在属性声明上,但网上有加到get方法上 ...
- SVN上传代码时代码失败
Description : You are not authorized to access the files in the repository.Suggestion : You might be ...