题目链接

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
 
三分套三分就可以了
  1. #include <iostream>
  2. #include <vector>
  3. #include <cstdio>
  4. #include <cstring>
  5. #include <algorithm>
  6. #include <cmath>
  7. #include <map>
  8. #include <set>
  9. #include <string>
  10. #include <queue>
  11. #include <stack>
  12. #include <bitset>
  13. using namespace std;
  14. #define pb(x) push_back(x)
  15. #define ll long long
  16. #define mk(x, y) make_pair(x, y)
  17. #define lson l, m, rt<<1
  18. #define mem(a) memset(a, 0, sizeof(a))
  19. #define rson m+1, r, rt<<1|1
  20. #define mem1(a) memset(a, -1, sizeof(a))
  21. #define mem2(a) memset(a, 0x3f, sizeof(a))
  22. #define rep(i, n, a) for(int i = a; i<n; i++)
  23. #define fi first
  24. #define se second
  25. typedef pair<int, int> pll;
  26. const double PI = acos(-1.0);
  27. const double eps = 1e-;
  28. const int mod = 1e9+;
  29. const int inf = ;
  30. const int dir[][] = { {-, }, {, }, {, -}, {, } };
  31. double xa, xb, xc, xd, ya, yb, yc, yd, p, q, r;
  32. double dis(double x1, double y1, double x2, double y2) {
  33. return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
  34. }
  35. double ternary(double x, double y) {
  36. double lx = xc, ly = yc, rx = xd, ry = yd;
  37. while(fabs(rx-lx)>eps || fabs(ry-ly)>eps) {
  38. double x1 = lx+(rx-lx)/, x2 = lx+(rx-lx)/*;
  39. double y1 = ly+(ry-ly)/, y2 = ly+(ry-ly)/*;
  40. double tmp1 = dis(x, y, x1, y1)/r+dis(x1, y1, xd, yd)/q+dis(x, y, xa, ya)/p;
  41. double tmp2 = dis(x, y, x2, y2)/r+dis(x2, y2, xd, yd)/q+dis(x, y, xa, ya)/p;
  42. if(tmp1>tmp2) {
  43. lx = x1, ly = y1;
  44. } else {
  45. rx = x2, ry = y2;
  46. }
  47. }
  48. return dis(x, y, lx, ly)/r+dis(lx, ly, xd, yd)/q+dis(x, y, xa, ya)/p;
  49. }
  50. double solve() {
  51. double lx = xa, rx = xb, ly = ya, ry = yb;
  52. while(fabs(rx-lx)>eps || fabs(ry-ly)>eps) {
  53. double x1 = lx+(rx-lx)/, x2 = lx+(rx-lx)/*;
  54. double y1 = ly+(ry-ly)/, y2 = ly+(ry-ly)/*;
  55. double tmp1 = ternary(x1, y1), tmp2 = ternary(x2, y2);
  56. if(tmp1>tmp2) {
  57. lx = x1, ly = y1;
  58. } else {
  59. rx = x2, ry = y2;
  60. }
  61. }
  62. return ternary(lx, ly);
  63.  
  64. }
  65. int main()
  66. {
  67. cin>>xa>>ya>>xb>>yb>>xc>>yc>>xd>>yd>>p>>q>>r;
  68. double ans = solve();
  69. printf("%.2f\n", ans);
  70. return ;
  71. }

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. 应用java多线程实现server端与多client之间的通信

    应用多线程来实现server与多线程之间的通信的基本步骤 1.server端创建ServerSocket,循环调用accept()等待client链接 2.client创建一个Socket并请求和se ...

  2. linux重新编译内核

    一.linux内核 1.查看linux内核版本 uname -r 2.下载对应的linux内核 https://www.kernel.org/pub/linux/kernel/ 将内核文件夹解压到/u ...

  3. html---textarea初始化时就有个table空格以及tab键操作无效

    1 初始化时就有一个tab空格 watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvRnJlZUFwZQ==/font/5a6L5L2T/fontsize/400 ...

  4. Matlab中用内建函数代替for循环

    在使用matlab进行矩阵计算的时候,经常会遇到要使用for循环的情况.但其实很多操作可以用内部的一些函数代替. bsxfun, arrayfun, cellfun, spfun, structfun ...

  5. SQlSERVER生成唯一编号

    基数表-用来存储编号前缀和类型 建表如下 CREATE TABLE [dbo].[SerialNo]( [sCode] [varchar](50) NOT NULL, [sName] [varchar ...

  6. pl sql项目演练--B2C商城项目

    项目学习视频下载地址:点击下载   1.注册会员及找回密码模块 }该模块主要功能有注册会员和找回密码 }注册会员:所需信息主要有:登录号.密码.真实姓名.性别.密码问题.密码答案.Email.地址.电 ...

  7. Git基本应用

    1.创建SSH Key $ cd ~/.ssh $ ssh-keygen -t rsa -C "your_email@example.com" 拷贝id_rsa.pub文件到Set ...

  8. c++中派生类对基类成员的三种访问规则(转)

    C++中派生类对基类成员的访问形式主要有以下两种:1.内部访问:由派生类中新增成员对基类继承来的成员的访问.2.对象访问:在派生类外部,通过派生类的对象对从基类继承来的成员的访问.今天给大家介绍在3中 ...

  9. input 属性

    1.readonly="readonly" 用来表示 input只能读写.

  10. mybaitis配置信息

    在配置mybatis当中,jdbcType的名称要大写,时间类型DATE只能传入年月日,要想传入时分秒,应该使用TIMESTAMP http://www.blogjava.net/hello-yun/ ...