两次三分

#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 三分的更多相关文章

  1. hdu 2899 hdu 3400 三分/几何

    hdu2899 : 水提,直接三分,事实上求导后二分也能够. #include<iostream> #include<cstdio> using namespace std; ...

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

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

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

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

  4. 三分 HDOJ 3714 Error Curves

    题目传送门 /* 三分:凹(凸)函数求极值 */ #include <cstdio> #include <algorithm> #include <cstring> ...

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

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

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

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

  7. [三分]HDOJ 5531 Rebuild

    题意:给n个点,以这n个点为圆心画圆,使得所有的圆与其相邻的圆相切. 求n个圆最小的面积和. 分析:很容易想到确定了其中一个圆的半径之后,其他的圆的半径也能随之确定了. 画一画三个点的和四个点的,会发 ...

  8. 【HDOJ】3400 Line belt

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

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

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

随机推荐

  1. TTB 基本

    中文名 ,线程构建模块 外文名 Thread Building Blocks 缩    写 TBB 开    发 intel 目录 1线程构建模块 2黑体亮温 3斜交载重轮胎 4串联球轴承     1 ...

  2. python查看删除你微信的账号

    #应用环境:python2.7 #!/usr/bin/env python # coding=utf-8 from __future__ import print_function import os ...

  3. 未能的导入项目,请确认<Import>声明中的路径正确

    对于这样的错误,根据提示应该是项目的管理文件(.csproj)中有问题.找到对应的位置修改即可

  4. cxf的使用及安全校验-02创建简单的客户端接口

    上一篇文章中,我们已经讲了如果简单的创建一个webservice接口 http://www.cnblogs.com/snowstar123/p/3395568.html 现在我们创建一个简单客户端接口 ...

  5. Js 时间间隔计算(间隔天数)

    function GetDateDiff(startDate,endDate)  {      var startTime = new Date(Date.parse(startDate.replac ...

  6. poj1562 DFS入门

    K - 搜索 Crawling in process... Crawling failed Time Limit:1000MS     Memory Limit:10000KB     64bit I ...

  7. C++读取一串不知个数的数字

    #include <iostream> using namespace std; int main(){ ]; ; while(cin>>shuzu[i]){ i++; } ; ...

  8. Python爬虫——抓取糗百段子

    在别人博客里学习的 抓取糗百段子,由于糗百不断的更新,代码需要改正. 抓取网页:http://www.qiushibaike.com/hot/page/1 修改后的代码如下: # -*- coding ...

  9. jquery 1.9 之后toggle不能用的问题

    今天用到toggle这个方法,发现不是自己想要的效果,之前有用过好多次,一直都没有问题. 网上查了原因,才知道是版本的问题,jquery1.9之后toggle取消了.那么如果想要继续用toggle的这 ...

  10. 慕课linux学习笔记(七)常用命令(4)

    帮助命令 Man命令 Man的级别 命令帮助 可被内核调用的函数帮助 函数和函数库帮助 特殊文件帮助 /dev 配置文件帮助 游戏的帮助 其他杂项的帮助 管理员可用命令帮助 内核相关文件的帮助 -f ...