在写这篇文章之前,xxx已经写过了几篇关于改枚举参考主题的文章,想要了解的朋友可以去翻一下之前的文章

http://202.197.224.59/OnlineJudge2/index.php/Problem/read/id/1175

每日一道理
感叹人生,是因为曾经没有过轰轰烈烈的壮举,觉得渺小,觉得平庸,似乎生活过于简单,简单得让人感觉烦躁。没有大言不惭地说过将来,只是比较现实地握住了现在,我想,这是一条路,每个人所必须踏上的一次旅程,曾经看到过这样一句话:成长的过程漫长却充实,自毁的过程短暂却留下一生痛苦,人生可以说是一次考验,何去何从取决于自我。

(2013湘潭邀请赛标题)

Hurry Up

Accepted : 62

Submit : 251

Time Limit : 1000 MS

Memory Limit : 65536 KB

Problem Description

GG is some what afraid of his MM. Once his MM asks, he will always try his best to rush to their home. 
Obvious, he can run home in straight line directly. Alternatively, he can run to the main road and call the taxi.
You can assume there is only one main road on the x-axis, with unlimited length.
Given the initial location of GG and his destination, please help to ask the minimize time to get home.
GG will always run at the fixed speed of vr, and the taxi can move at the fixed speed of vt 
You can also assume that, only GG reach the main road, he can catch the taxi immediately. And the taxi will go towards home ( not necessay along the road ). 
Bisides, GG can run arbitrary length, and pay arbitrarily for the taxi.

P.S. MM: abbr. Ma Ma

Input

Multiple test cases. First line, an integer T ( 1 ≤ T ≤ 2000 ), indicating the number of test cases. 
For each test cases, there are 6 integers x1, y1, x2, y2, vr, vt in a line. 
( -1000 <= x1, y1, x2, y2 <= 1000, 1 <= vr < vt <= 1000 ) 
(x1, y1) : the initial location of GG 
(x2, y2) : the destination location of GG 
vr: GG's run speed 
vt: taxi's speed

Ouput

For each test case, output a real number with 2 digits after the arithmetic point. It is the shorest time for GG to reach home.

Sample Input

2

1 1 2 2 1 2

1 1 2 2 1 7

Sample Output

1.41

1.32

Source

XTU OnlineJudge

[ Submit Solution ]

//正解一

memory      time             length1064 KB  31 MS      1123 B#include<string.h>#include<stdio.h>#include<math.h>#include<algorithm>#include <iostream>using namespace std;const double ep=1e-10;double vr,vt;double xt,x2;double y2,yt;double lenth(double a1,double b1,double a2,double b2){return sqrt((a1-a2)*(a1-a2)+(b1-b2)*(b1-b2));}double caltime(double x){return (lenth(xt,yt,x,0)/vr+lenth(x2,y2,x,0)/vt);}int main(){int T,i;double t1,t2,r,l;while(scanf("%d",&T)!=EOF){for(i=0;i<T;i++){scanf("%lf%lf%lf%lf",&xt,&yt,&x2,&y2);scanf("%lf%lf",&vr,&vt);t1=lenth(xt,yt,x2,y2)/vr;r=xt;l=x2;for(int i=0;i<100;i++)//这么多是参考某位大神的{  double m1=l + (r-l)/3;double m2=r - (r-l)/3;if(caltime(m1)<=caltime(m2))  r=m2;else  l=m1;}t2=caltime(l);t1=t1<t2? t1:t2;printf("%.2lf\n",t1);}}return 0;}正解二:/枚举法memory      time             length
1256 KB     593 MS      1176 B//枚举法,枚举到0.1#include<string.h>#include<stdio.h>#include<math.h>#include<algorithm>#include <iostream>using namespace std;const double ep=1e-10;double vr,vt;double xt,x2;double y2,yt;double lenth(double a1,double b1,double a2,double b2){return sqrt((a1-a2)*(a1-a2)+(b1-b2)*(b1-b2));}double caltime(int x){    (double)x;return (lenth(xt,yt,x,0)/vr+lenth(x2,y2,x,0)/vt);}int main(){int T,i,j;double t1,t2,min,max,t;while(scanf("%d",&T)!=EOF){for(i=0;i<T;i++){scanf("%lf%lf%lf%lf",&xt,&yt,&x2,&y2);xt=xt*10.0;yt=yt*10.0;x2=x2*10.0;y2=y2*10.0;scanf("%lf%lf",&vr,&vt);vr=vr*10.0;vt=vt*10.0;t1=lenth(xt,yt,x2,y2)/vr;max=xt>x2? xt:x2;min=xt<x2? xt:x2;t2=1000000.0;for(j=(int)min;j<=(int)max;j++){t=caltime(j);if(t2>t)t2=t;}t1=t1<t2? t1:t2;printf("%.2lf\n",t1);}}return 0;}错误://三分法#include<string.h>#include<stdio.h>#include<math.h>#include<algorithm>#include <iostream>using namespace std;const double ep=1e-10;double vr,vt;double xt,x2;double y2,yt;double lenth(double a1,double b1,double a2,double b2){return sqrt((a1-a2)*(a1-a2)+(b1-b2)*(b1-b2));}double caltime(double x){return (lenth(xt,yt,x,0)/vr+lenth(x2,y2,x,0)/vt);}double solve(double l,double r)//三分法{double m;double mm;while(l+ep<r){m=(l+r)/2.0;mm=(m+r)/2.0;if(caltime(m)<caltime(mm))//取最小值r=mm;elsel=m;}return l;}int main(){int T,i;double t1,t2;while(scanf("%d",&T)!=EOF){for(i=0;i<T;i++){scanf("%lf%lf%lf%lf",&xt,&yt,&x2,&y2);scanf("%lf%lf",&vr,&vt);t1=lenth(xt,yt,x2,y2)/vr;t2=caltime(solve(xt,x2));t1=t1<t2? t1:t2;printf("%.2lf\n",t1);}}return 0;}

文章结束给大家分享下程序员的一些笑话语录: Borland说我很有前途,Sun笑了;Sun说我很有钱,IBM笑了;IBM说我很专业,Sybase笑了;Sybase说我数据库很牛,Oracle笑了;Oracle说我是开放的,Linux笑了;Linux说我要打败Unix,微软笑了;微软说我的系统很稳定,我们都笑了。

--------------------------------- 原创文章 By
枚举和参考
---------------------------------

枚举参考Hurry Up(三分)相关推荐

  1. 2013数据结构课程设计之便利店选址(暴力枚举或随机函数或三分)

    [问题描述] 某小区决定在小区内部建一家便利店,现小区内部共有八栋楼,它们的地理坐标分别为:(10,20) (30,34) (19,25) (38,49.1) (9,38.1) (2,34) (5,8 ...

  2. oracle 枚举_枚举导出为sql语句java实现

    //运行main方法,拷贝控制台输出的内容,就是sql语句了,放到oracle执行插入(sql仅供参考,具体看自己的表结构)public static void main(String[] args) ...

  3. 微软codepush搭建服务器,通过 CodePush API 参考对本机 SDK 作出响应 - Visual Studio App Center | Microsoft Docs...

    响应 Native Client SDK API 参考 02/19/2020 本文内容 CodePush 插件由以下两个组件组成: 可以导入/要求的 JavaScript 模块,并允许应用在运行时与服 ...

  4. 谈Java语言规范之枚举类型

    文章目录 枚举类型 一. 枚举常量 二.枚举主体声明 对枚举常数自我引用的限制: 三.枚举成员 这不是一顿快餐,希望你沉淀下来,细细品尝 写在前面 枚举类型可以考虑用来替换接口中的常量声明.并且 &l ...

  5. linux枚举pcie设备,pcie设备枚举(转载)

    转载自chinaunix 枚举所有PCI设备 冷胜魁(Seaquester) lengshengkui@gmail.com 2009-11-16 在Linux下,lspci可以枚举所有PCI设备.它是 ...

  6. 13.QT信号槽的连接方式

    QT的信号槽机制和线程的启动方式已经在前面的文章中写过了,本文主要是对信号槽的连接方式进行解读,信号槽的连接方式一共有5种: 1.Qt::DirectConnection 发出信号后立即调用槽函数. ...

  7. [***]HZOJ 柱状图

    神仙题. 作者的正解: 算法二:对于60%的数据:考虑直接枚举屋顶的位置,总花费与屋顶的高度的关系是一个单峰函数,,我们可以用三分法三分屋顶的高度. 时间复杂度O(n2*logn).   算法三:对于 ...

  8. [ZJOI2008]瞭望塔

    题目描述 致力于建设全国示范和谐小村庄的H村村长dadzhi,决定在村中建立一个瞭望塔,以此加强村中的治安. 我们将H村抽象为一维的轮廓.如下图所示 我们可以用一条山的上方轮廓折线(x1, y1), ...

  9. POJ3737 UmBasketella

    嘟嘟嘟 一道三分入门题. 参考二分,三分就是每一次把区间分成三段,然后舍弃一段,不断缩小范围直到一个点. 一般用于求单峰函数的最值问题. 这道题发现V和r成一次函数的关系,因此三分r. 下面给出三分板 ...

最新文章

  1. Xamarin Anroid开发教程之Anroid开发工具及应用介绍
  2. H.264编码系统几个比较重要的算法
  3. Python 类的多态
  4. 【机器学习】支持向量机(SVM)代码练习
  5. c++字符串大小比较可以用来干什么?
  6. Linux的基本使用
  7. python相比于excel的优势_对照Excel使用Python进行数据分析,更快掌握
  8. 【Spark】快速简介
  9. exchange 管理员只有创建新用户无删除的权限设定方法
  10. 循环神经网络 递归神经网络_递归神经网络-第5部分
  11. python敲七游戏代码_敲七游戏数字表
  12. u盘怎么装服务器系统教程,u盘装服务器系统教程
  13. 苹果服务器系统状态查询网站,mac电脑服务器地址怎么查看
  14. 肥猫学习笔记---C语言数据结构与算法(一)-----栈
  15. Android Q USB Tethering 端口切换分析
  16. SwiftUI学习(一)
  17. Flutter杂症(couldn't find libflutter.so)
  18. noip2014 珠心算测验 (枚举)
  19. C++ 设计模式 适配器模式(中英翻译, Win-Linux翻译)
  20. C. Equalize

热门文章

  1. WEB应用常见15种安全漏洞一览
  2. 十分钟轻松让你认识Entity Framework 7
  3. spring session 退出登录 清理session
  4. nagios监控远程端口
  5. 前端基础知识 - 收藏集 - 掘金
  6. POJ 3180 Tarjan
  7. MySQL/InnoDB处理AUTO_INCREMENT(二)
  8. linux 文件与目录管理命令
  9. .NET Core微服务之路:不断更新中的目录 (v0.42)
  10. linux编译安装网卡驱动详解(网卡丢包)