HDU3400 三分套三分
题意
就是给你两条线段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 三分套三分的更多相关文章
- BZOJ 1857 传送带 (三分套三分)
在一个2维平面上有两条传送带,每一条传送带可以看成是一条线段.两条传送带分别为线段AB和线段CD.lxhgww在AB上的移动速度为P,在CD上的移动速度为Q,在平面上的移动速度R.现在lxhgww想从 ...
- 【BZOJ-1857】传送带 三分套三分
1857: [Scoi2010]传送带 Time Limit: 1 Sec Memory Limit: 64 MBSubmit: 1077 Solved: 575[Submit][Status][ ...
- bzoj1857: [Scoi2010]传送带--三分套三分
三分套三分模板 貌似只要是单峰函数就可以用三分求解 #include<stdio.h> #include<string.h> #include<algorithm> ...
- 三分套三分 --- HDU 3400 Line belt
Line belt Problem's Link: http://acm.hdu.edu.cn/showproblem.php?pid=3400 Mean: 给出两条平行的线段AB, CD,然后一 ...
- [luogu2571][bzoj1857][SCOI2010]传送门【三分套三分】
题目描述 在一个2维平面上有两条传送带,每一条传送带可以看成是一条线段.两条传送带分别为线段AB和线段CD.lxhgww在AB上的移动速度为P,在CD上的移动速度为Q,在平面上的移动速度R.现在lxh ...
- 2018.06.30 BZOJ1857: [Scoi2010]传送带(三分套三分)
1857: [Scoi2010]传送带 Time Limit: 1 Sec Memory Limit: 64 MB Description 在一个2维平面上有两条传送带,每一条传送带可以看成是一条线段 ...
- 【BZOJ1857】[Scoi2010]传送带 三分套三分
[BZOJ1857][Scoi2010]传送带 Description 在一个2维平面上有两条传送带,每一条传送带可以看成是一条线段.两条传送带分别为线段AB和线段CD.lxhgww在AB上的移动速度 ...
- 【BZOJ1857】传送带(分治经典:三分套三分)
点此看题面 大致题意: 一个二维平面上有两条传送带\(AB\)和\(CD\),\(AB\)传送带的移动速度为\(P\),\(CD\)传送带的移动速度为\(Q\),步行速度为\(R\),问你从\(A\) ...
- loj10017. 「一本通 1.2 练习 4」传送带(三分套三分)
题目描述 在一个2维平面上有两条传送带,每一条传送带可以看成是一条线段.两条传送带分别为线段AB和线段CD.lxhgww在AB上的移动速度为P,在CD上的移动速度为Q,在平面上的移动速度R.现在lxh ...
- 最小球覆盖——模拟退火&&三分套三分套三分
题目 给出 $N(1 \leq N \leq 100)$ 个点的坐标 $x_i,y_i,z_i$($-100000 \leq x_i,y_i,z_i \leq 100000$),求包围全部点的最小的球 ...
随机推荐
- Logistic回归 逻辑回归 练习——以2018建模校赛为数据源
把上次建模校赛一个根据三围将女性分为四类(苹果型.梨形.报纸型.沙漏)的问题用逻辑回归实现了,包括从excel读取数据等一系列操作. Excel的格式如下:假设有r列,则前r-1列为数据,最后一列为类 ...
- 微信小程序-----自定义验证码实现
这一段时间做小程序项目,使用的是mpvue的框架,需要自己实现验证码输入,模拟input的光标,上一个框输入后后一个框自动获取焦点,删除时从后往前依次删除.下图是整体效果: <template& ...
- javascript event对象操作
js代码: $(".leads_detail").click(function(e){ e = e || event; var t = e.target || e.srcEleme ...
- World Cup(思维+模拟)
Description Allen wants to enter a fan zone(球迷区) that occupies a round square and has nn entrances. ...
- Alpha冲刺——第十天
Alpha第十天 听说 031502543 周龙荣(队长) 031502615 李家鹏 031502632 伍晨薇 031502637 张柽 031502639 郑秦 1.前言 任务分配是VV.ZQ. ...
- Java GUI 点击按钮退出
import java.awt.*; import java.awt.event.*; public class TestFrameTwo implements ActionListener { Fr ...
- C#高级编程 (第六版) 学习 第一章:.Net体系结构
第一章 .Net体系结构 1,公共语言运行库(Common Language Runtime, CLR) .Net Framework的核心是其运行库的执行环境,称为公共语言运行库,或.Net运行库. ...
- 修改表中的enum字段
alter table 表名 modify 字段名 enum('system','audit','account','secadmin') DEFAULT NULL;
- mysql中(存储)函数
(存储)函数: 函数,也说成“存储函数”,其实就是js或php中所说的函数! 唯一的区别: 这里的函数必须返回一个数据(值): 定义形式: 注意事项: 1, 在函数内部,可以有各种变量和流程控制的使用 ...
- MySQL---InnoDB引擎隔离级别详解
原帖:http://www.cnblogs.com/snsdzjlz320/p/5761387.html SQL标准定义了4种隔离级别,包括了一些具体规则,用来限定事务内外的哪些改变是可见的,哪些是不 ...