题意

就是给你两条线段AB , CD ,一个人在AB以速度p跑,在CD上以q跑,

在其他地方跑速度是r。问你从A到D最少的时间。

三分AB ,然后再三分CD ,模板题目,这题卡精度 eps不能少

 #include <cstdio>
#include <cstring>
#include <queue>
#include <cmath>
#include <algorithm>
#include <set>
#include <iostream>
#include <map>
#include <stack>
#include <string>
#include <vector>
#define pi acos(-1.0)
#define eps 1e-9
#define fi first
#define se second
#define rtl rt<<1
#define rtr rt<<1|1
#define bug printf("******\n")
#define mem(a,b) memset(a,b,sizeof(a))
#define name2str(x) #x
#define fuck(x) cout<<#x" = "<<x<<endl
#define f(a) a*a
#define sf(n) scanf("%d", &n)
#define sff(a,b) scanf("%d %d", &a, &b)
#define sfff(a,b,c) scanf("%d %d %d", &a, &b, &c)
#define sffff(a,b,c,d) scanf("%d %d %d %d", &a, &b, &c, &d)
#define pf printf
#define FRE(i,a,b) for(i = a; i <= b; i++)
#define FREE(i,a,b) for(i = a; i >= b; i--)
#define FRL(i,a,b) for(i = a; i < b; i++)+
#define FRLL(i,a,b) for(i = a; i > b; i--)
#define FIN freopen("data.txt","r",stdin)
#define gcd(a,b) __gcd(a,b)
#define lowbit(x) x&-x
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const int mod = 1e9 + ;
const int maxn = 2e5 + ;
const int INF = 0x3f3f3f3f;
const LL INFLL = 0x3f3f3f3f3f3f3f3fLL;
int t;
double P, Q, R, len1, len2;
struct node {
double x, y;
} a, b, c, d, temp1, temp2;
double dist ( node a, node b ) {
return sqrt ( eps + ( a.x - b.x ) * ( a.x - b.x ) + ( a.y - b.y ) * ( a.y - b.y ) );
}
void caltemp1 ( double cnt ) {
temp1.x = a.x + ( b.x - a.x ) / len1 * cnt;
temp1.y = a.y + ( b.y - a.y ) / len1 * cnt;
}
void caltemp2 ( double cnt ) {
temp2.x = d.x + ( c.x - d.x ) / len2 * cnt;
temp2.y = d.y + ( c.y - d.y ) / len2 * cnt;
}
double check ( double cnt ) {
caltemp1 ( cnt );
double l = , r = len2, ll, rr, ans1, ans2;
while ( r - l > eps ) {
ll = ( * l + r ) / , rr = ( * r + l ) / ;
caltemp2 ( ll );
ans1 = dist ( temp1, temp2 ) / R + dist ( d, temp2 ) / Q;
caltemp2 ( rr );
ans2 = dist ( temp1, temp2 ) / R + dist ( d, temp2 ) / Q;
if ( ans1 < ans2 ) r = rr;
else l = ll;
}
return ans1 + dist ( temp1, a ) / P;
}
int main() {
scanf ( "%d", &t );
while ( t-- ) {
scanf ( "%lf%lf%lf%lf", &a.x, &a.y, &b.x, &b.y );
scanf ( "%lf%lf%lf%lf", &c.x, &c.y, &d.x, &d.y );
scanf ( "%lf%lf%lf", &P, &Q, &R );
len1 = dist ( a, b ), len2 = dist ( c, d );
double l = , r = len1, ll, rr;
while ( r - l > eps ) {
ll = ( * l + r ) / , rr = ( * r + l ) / ;
if ( check ( ll ) < check ( rr ) ) r = rr;
else l = ll;
}
printf ( "%.2f\n", check ( ll ) );
}
return ;
}

HDU3400 三分套三分的更多相关文章

  1. BZOJ 1857 传送带 (三分套三分)

    在一个2维平面上有两条传送带,每一条传送带可以看成是一条线段.两条传送带分别为线段AB和线段CD.lxhgww在AB上的移动速度为P,在CD上的移动速度为Q,在平面上的移动速度R.现在lxhgww想从 ...

  2. 【BZOJ-1857】传送带 三分套三分

    1857: [Scoi2010]传送带 Time Limit: 1 Sec  Memory Limit: 64 MBSubmit: 1077  Solved: 575[Submit][Status][ ...

  3. bzoj1857: [Scoi2010]传送带--三分套三分

    三分套三分模板 貌似只要是单峰函数就可以用三分求解 #include<stdio.h> #include<string.h> #include<algorithm> ...

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

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

  5. [luogu2571][bzoj1857][SCOI2010]传送门【三分套三分】

    题目描述 在一个2维平面上有两条传送带,每一条传送带可以看成是一条线段.两条传送带分别为线段AB和线段CD.lxhgww在AB上的移动速度为P,在CD上的移动速度为Q,在平面上的移动速度R.现在lxh ...

  6. 2018.06.30 BZOJ1857: [Scoi2010]传送带(三分套三分)

    1857: [Scoi2010]传送带 Time Limit: 1 Sec Memory Limit: 64 MB Description 在一个2维平面上有两条传送带,每一条传送带可以看成是一条线段 ...

  7. 【BZOJ1857】[Scoi2010]传送带 三分套三分

    [BZOJ1857][Scoi2010]传送带 Description 在一个2维平面上有两条传送带,每一条传送带可以看成是一条线段.两条传送带分别为线段AB和线段CD.lxhgww在AB上的移动速度 ...

  8. 【BZOJ1857】传送带(分治经典:三分套三分)

    点此看题面 大致题意: 一个二维平面上有两条传送带\(AB\)和\(CD\),\(AB\)传送带的移动速度为\(P\),\(CD\)传送带的移动速度为\(Q\),步行速度为\(R\),问你从\(A\) ...

  9. loj10017. 「一本通 1.2 练习 4」传送带(三分套三分)

    题目描述 在一个2维平面上有两条传送带,每一条传送带可以看成是一条线段.两条传送带分别为线段AB和线段CD.lxhgww在AB上的移动速度为P,在CD上的移动速度为Q,在平面上的移动速度R.现在lxh ...

  10. 最小球覆盖——模拟退火&&三分套三分套三分

    题目 给出 $N(1 \leq N \leq 100)$ 个点的坐标 $x_i,y_i,z_i$($-100000 \leq x_i,y_i,z_i \leq 100000$),求包围全部点的最小的球 ...

随机推荐

  1. Java Basic&Security Tools

    JDK Tools and Utilities Basic Tools These tools are the foundation of the JDK. They are the tools yo ...

  2. Apriori 获取关联规则实现

    前言 自己的一个Apriori 获取关联规则的python实现.具体原理不讲,代码添加了说明,还是很好理解的. 数据预处理 #最小置信度 min_conf = 0.5 #最小支持度 min_sup = ...

  3. python打印图形大全(详解)

    ,): shixin=chr() print(shixin) -------------------结果:2) for i in range(0,10): shixin=chr(9679) print ...

  4. linux 命令自动补全包

    linux 其他知识目录 rhel7如果使用最小化安装后,tab键默认是不能自动补全命令的 执行yum install bash-completion之后重启系统正常.

  5. C# string 常用方法

    string.ToString().Contains() String str="abcd" str.ToString().Contains("a"); //t ...

  6. Python:模块学习——sys模块

    sys模块常见函数和变量 sys.argv:命令行参数,实现从程序外部向程序传递参数 [注]:(1) sys.argv[0] 表示代码本身的文件路径 (2)sys.argv是一个元组,可以用[ ]提取 ...

  7. 线段树-hdu2795 Billboard(贴海报)

    hdu2795 Billboard 题意:h*w的木板,放进一些1*L的物品,求每次放空间能容纳且最上边的位子 思路:每次找到最大值的位子,然后减去L 线段树功能:query:区间求最大值的位子(直接 ...

  8. 博弈---ZOJ 2083 Win the Game(染绳子)

    原题:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2083 大意:两个人分别对n条绳子染 每次染m长 最后染不下的输,问先 ...

  9. 桥接,NAT,Host Only的区别

    桥接,NAT,Host Only的区别   一.Brigde——桥接 :默认使用VMnet0fish批注:只要在虚拟机中将IP设对,即使宿主机的IP是错的,也可以通信.但是如此物理网卡被禁用了,则不能 ...

  10. 当对象使用sort时候 前提是实现compareTo的方法