题意

就是给你两条线段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. 深度学习论文笔记:Deep Residual Networks with Dynamically Weighted Wavelet Coefficients for Fault Diagnosis of Planetary Gearboxes

    这篇文章将深度学习算法应用于机械故障诊断,采用了“小波包分解+深度残差网络(ResNet)”的思路,将机械振动信号按照故障类型进行分类. 文章的核心创新点:复杂旋转机械系统的振动信号包含着很多不同频率 ...

  2. C#判断字符串中是否有数字

    // <summary> /// 提取字符串中的数字字符串 /// </summary> /// <param name="str"></ ...

  3. nginx响应client的处理机制

    nginx与apache的不同响应机制——epoll nginx可以处理上百万级别的并发请求就是源至于异步非阻塞的处理机制,异步非阻塞核心即是epoll nginx内部反向代理

  4. 第二次程序+PSP0级

    第二周,老师接着上次的程序有对四则运算的程序,做出来一些要求,这次要求可以控制乘除法,有无括号,控制输出方式,控制结果有无负数,有无余数. 我在对原先的程序分析了一下,发现我原先的程序可扩展性特别差, ...

  5. 各团队对《t铁大导航》评价及我组回复

    组名 对我们组的建议 我组回复 (1)跑男 你们的导航前期要做到什么样的程度呢?其实我一直是很期待你们完成时我能够用你们的导航来感受一下咱们铁大校园风情.你们用了数据结构算法来找最短路径,那你们能不能 ...

  6. 如何利用Xshell在Linux下安装jdk

    本文会详细介绍如何在Linux下安装JDK1.8 首先要设置虚拟机的IP地址,不知道如何设置的话可以 翻看我的前一篇博客   http://www.cnblogs.com/xiaoxiaoSMILE/ ...

  7. Java 静态代码块&构造代码块&局部代码块

    /* 静态代码块. 随着类的加载而执行.而且只执行一次. 作用: 用于给类进行初始化. */ class StaticCode { static int num ; static { num = 10 ...

  8. PXE Centos7和Centos6

    外网网卡:192.168.23.10, 内网网卡:192.168.10.2 PXE(preboot execute environment,预引导执行环境)是由Intel公司开发的最新技术,工作于Cl ...

  9. 【Leetcode】50. Pow(x, n)

    Implement pow(x, n). Example 1: Input: 2.00000, 10 Output: 1024.00000 Example 2: Input: 2.10000, 3 O ...

  10. 使用union all 遇到的问题(俩条sql语句行数的和 不等于union all 后的 行数的和 !);遗留问题 怎么找到 相差的呐俩条数据 ?

    create table buyer as SELECT b.id AS bankid FROM v_product_deal_main m, base_member b WHERE b.id = m ...