题目链接

1857: [Scoi2010]传送带

Time Limit: 1 Sec  Memory Limit: 64 MB
Submit: 934  Solved: 501
[Submit][Status][Discuss]

Description

在一个2维平面上有两条传送带,每一条传送带可以看成是一条线段。两条传送带分别为线段AB和线段CD。lxhgww在AB上的移动速度为P,在CD上的移动速度为Q,在平面上的移动速度R。现在lxhgww想从A点走到D点,他想知道最少需要走多长时间

Input

输入数据第一行是4个整数,表示A和B的坐标,分别为Ax,Ay,Bx,By 第二行是4个整数,表示C和D的坐标,分别为Cx,Cy,Dx,Dy 第三行是3个整数,分别是P,Q,R

Output

输出数据为一行,表示lxhgww从A点走到D点的最短时间,保留到小数点后2位

Sample Input

0 0 0 100
100 0 100 100
2 2 1

Sample Output

136.60
 
三分套三分就可以了
#include <iostream>
#include <vector>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <stack>
#include <bitset>
using namespace std;
#define pb(x) push_back(x)
#define ll long long
#define mk(x, y) make_pair(x, y)
#define lson l, m, rt<<1
#define mem(a) memset(a, 0, sizeof(a))
#define rson m+1, r, rt<<1|1
#define mem1(a) memset(a, -1, sizeof(a))
#define mem2(a) memset(a, 0x3f, sizeof(a))
#define rep(i, n, a) for(int i = a; i<n; i++)
#define fi first
#define se second
typedef pair<int, int> pll;
const double PI = acos(-1.0);
const double eps = 1e-;
const int mod = 1e9+;
const int inf = ;
const int dir[][] = { {-, }, {, }, {, -}, {, } };
double xa, xb, xc, xd, ya, yb, yc, yd, p, q, r;
double dis(double x1, double y1, double x2, double y2) {
return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}
double ternary(double x, double y) {
double lx = xc, ly = yc, rx = xd, ry = yd;
while(fabs(rx-lx)>eps || fabs(ry-ly)>eps) {
double x1 = lx+(rx-lx)/, x2 = lx+(rx-lx)/*;
double y1 = ly+(ry-ly)/, y2 = ly+(ry-ly)/*;
double tmp1 = dis(x, y, x1, y1)/r+dis(x1, y1, xd, yd)/q+dis(x, y, xa, ya)/p;
double tmp2 = dis(x, y, x2, y2)/r+dis(x2, y2, xd, yd)/q+dis(x, y, xa, ya)/p;
if(tmp1>tmp2) {
lx = x1, ly = y1;
} else {
rx = x2, ry = y2;
}
}
return dis(x, y, lx, ly)/r+dis(lx, ly, xd, yd)/q+dis(x, y, xa, ya)/p;
}
double solve() {
double lx = xa, rx = xb, ly = ya, ry = yb;
while(fabs(rx-lx)>eps || fabs(ry-ly)>eps) {
double x1 = lx+(rx-lx)/, x2 = lx+(rx-lx)/*;
double y1 = ly+(ry-ly)/, y2 = ly+(ry-ly)/*;
double tmp1 = ternary(x1, y1), tmp2 = ternary(x2, y2);
if(tmp1>tmp2) {
lx = x1, ly = y1;
} else {
rx = x2, ry = y2;
}
}
return ternary(lx, ly); }
int main()
{
cin>>xa>>ya>>xb>>yb>>xc>>yc>>xd>>yd>>p>>q>>r;
double ans = solve();
printf("%.2f\n", ans);
return ;
}

bzoj 1857: [Scoi2010]传送带 三分的更多相关文章

  1. Bzoj 1857: [Scoi2010]传送带(三分套三分)

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

  2. BZOJ 1857: [Scoi2010]传送带

    二次联通门 : BZOJ 1857: [Scoi2010]传送带 /* BZOJ 1857: [Scoi2010]传送带 三分套三分 可能是吧..dalao们都说明显是一个单峰函数 可是我证不出来.. ...

  3. BZOJ 1857: [Scoi2010]传送带(三分套三分)

    Time Limit: 1 Sec Memory Limit: 64 MB Submit: 2549 Solved: 1370 [Submit][Status][Discuss] Descriptio ...

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

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

  5. 【BZOJ】1857: [Scoi2010]传送带(三分)

    http://www.lydsy.com/JudgeOnline/problem.php?id=1857 好神奇的三分.. 第一次写三分啊sad..看了题解啊题解QAQ 首先发现无论怎么走一定是在AB ...

  6. BZOJ 2131 [scoi2010] 传送带

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

  7. 洛谷P2571 [SCOI2010]传送带 [三分]

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

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

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

  9. [BZOJ1857][SCOI2010]传送带-[三分]

    Description 传送门 Solution 三分套三分.代码简单但是证明苦兮兮.. 假如我们在AB上选了一个点G,求到该点到D的最小时间. 图中b与CD垂直.设目前从G到D所耗时间最短的路径为G ...

随机推荐

  1. thenjs的应用

    <!doctype html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  2. mysql关联更新

    update tb_sdd_info a,tb_bnm_evian_info b set a.username=b.username where a.username=b.memberno and  ...

  3. 动态加载 js

    要实现动态加载JS脚本有4种方法: 1.直接document.write <script language="javascript"> document.write(& ...

  4. sql大数据量查询的优化技巧

    1.对查询进行优化,应尽量避免全表扫描,首先应考虑在 where 及 order by 涉及的列上建立索引. 2.应尽量避免在 where 子句中对字段进行 null 值判断,否则将导致引擎放弃使用索 ...

  5. C和C++运算符 (转)

    这里是C和C++语言的运算符列表.所有列出的运算符皆含纳于C++:第三个栏目里的内容也使用C来描述.应当注意的是C不支持运算符重载. 下列运算符在两个语言中都是顺序点(运算符未重载时): && ...

  6. leetcode two sum python

    class Solution: # @param {integer[]} nums # @param {integer} target # @return {integer[]} def twoSum ...

  7. Linux命令之修改主机名

    ubuntu永久修改主机名 1.查看主机名 在Ubuntu系统中,快速查看主机名有多种方法: 其一,打开一个GNOME终端窗口,在命令提示符中可以看到主机名,主机名通常位于“@”符号后: 其二,在终端 ...

  8. centos 安装mysql密码修改后还是不能连接的原因

    centos 上安装mysql密码修改后还是不能连接出现错误:ERROR 1142 (42000): SELECT command denied to user ''@'localhost' for ...

  9. 老旧Webkit浏览器行内元素0间距问题

    有时我们希望display:inline-block的元素之间的天衣无缝.紧密相依,比如说如下的情情形: 一般情况下我们使用如下代码可以实现: .pageNav { font-size:; text- ...

  10. Android Gradle配置

    解决问题 错误: Could not find the AndroidManifest.xml file, going up from path //打开app build.gradle文件加入以下代 ...