两次三分

#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. [IOI1999]花店橱窗布置(DP路径记录)

    题目:[IOI1999]花店橱窗布置 问题编号:496 题目描述 某花店现有F束花,每一束花的品种都不一样,同时至少有同样数量的花瓶,被按顺序摆成一行,花瓶的位置是固定的,从左到右按1到V顺序编号,V ...

  2. const与define的异同

    1. DEFINE是预处理指令,是简单的文字替换:而const是关键字,用于变量声明的修饰. 2. DEFINE替换的结果可以是数值.表达式.字符串.甚至是一个程序:而const只能限定变量为不可修改 ...

  3. css3 tranform  transition animation

    tranform:对象图形变形 tranform的属性包括:   1.none 表示不进行变换:   2.rotate 旋转            transform:rotate(20deg) 旋转 ...

  4. seajs初尝 加载jquery返回null解决学习日志含示例下载

    原文地址:http://www.tuicool.com/articles/bmuaEb 如需demo示例,请点击下方链接下载: http://yunpan.cn/cVEybKs8nV7CF  提取码 ...

  5. Linux 下安装oracle数据库

    原文出处       http://www.linuxidc.com/Linux/2015-02/113222.html 需要安装Oracle DataGuard,所以先要安装单台Oracle11g, ...

  6. angular 指令梳理 —— 前端校验

    angular js内置校验的扩展 校验成功则 scope.formName.$valid=true 校验失败  元素的class: ng-invalid 成功:.ng-valid /** * 校验指 ...

  7. js中window.print()去除页眉页脚

    //jsp打印时去除页眉页页脚 打印前加入下面代码即可 var HKEY_Root,HKEY_Path,HKEY_Key; HKEY_Root="HKEY_CURRENT_USER" ...

  8. IP地址变动后,https://localhost:1158/em无法访问解决办法

    一.解决的方法:重新配置em 二.步骤: 1.在 dos命令下输入 emca –repos drop 注意:监听端口号是一般是1521,特殊情况要在配置文件中找 2.成功删除资料档案库后,在dos下再 ...

  9. SVN的初步使用方法

    1.需要公司提供SVN账号密码 2.cd 输入本地存储路径 3.输入服务器地址 --uesr= (账号名) --password=(账号密码) 4.本地路径会自动创建文件 5.经理会初始化项目 5.1 ...

  10. C#this的五种用法

    this的五种用法: 1.使用被掩盖的成员变量: class AA { int a; public void set1(int a) { this.a = a;//right } public voi ...