Codeforces Round #365 (Div. 2) C - Chris and Road 二分找切点
// Codeforces Round #365 (Div. 2)
// C - Chris and Road 二分找切点
// 题意:给你一个凸边行,凸边行有个初始的速度往左走,人有最大速度,可以停下来,竖直走。
// 问走到终点的最短时间
// 思路:
// 1.贪心来做
// 2.我觉的二分更直观
// 可以抽象成:一条射线与凸边行相交,判断交点。二分找切点 #include <bits/stdc++.h>
using namespace std;
#define LL long long
const int inf = 0x3f3f3f3f;
const int MOD =;
const int N =1e6+;
#define clc(a,b) memset(a,b,sizeof(a))
const double eps = 1e-;
struct Point{
double x,y;
Point(){}
Point(int x_,int y_):x(x_),y(y_){}
Point operator + (const Point &t)const{
return Point(x+t.x,y+t.y);
}
Point operator - (const Point &t)const{
return Point(x-t.x,y-t.y);
}
double operator * (const Point &t)const{
return x*t.y-y*t.x;
}
double operator ^ (const Point &t)const{
return x*t.x+y*t.y;
}
bool operator < (const Point & a) const{
if(x==a.x) return y>a.y;
return x<a.x;
}
}p[]; int n;
bool judge(double k,double b){
int tot=,cnt=;
for(int i=;i<=n;i++){
if(k*p[i].x+b-p[i].y<) tot++;
else cnt++;
if(cnt&&tot) return false;
}
return true;
}
int main(){
int w;
double v,u;
scanf("%d%d%lf%lf",&n,&w,&v,&u);
for(int i=;i<=n;i++){
scanf("%lf%lf",&p[i].x,&p[i].y);
}
double k=u/v;
if(judge(k,0.0)){
printf("%.8f\n",(double)(w/u));
}
else{
double l=,r=1e9;
double ans;
while(r-l>eps){
double mid = (l+r)/2.0;
if(judge(k,-mid/v*u)){
ans=(double)(w/u)+mid/v;
r=mid;
}
else{
l=mid;
}
}
printf("%.8f\n",ans);
}
return ;
}
Codeforces Round #365 (Div. 2) C - Chris and Road 二分找切点的更多相关文章
- Codeforces Round #365 (Div. 2) Chris and Road
		
Chris and Road 题意: 给一个n个顶点的多边形的车,有速度v,人从0走到对面的w,人速度u,问人最快到w的时间是多少,车如果挡到人,人就不能走. 题解: 这题当时以为计算几何,所以就没做 ...
 - Codeforces Round #365 (Div. 2)
		
A题 Mishka and Game 水..随便统计一下就A了 #include <cstdio> #include <map> #include <set> #i ...
 - Codeforces Round #365 (Div. 2) A 水
		
A. Mishka and Game time limit per test 1 second memory limit per test 256 megabytes input standard i ...
 - Codeforces Round #369 (Div. 2) B. Chris and Magic Square 水题
		
B. Chris and Magic Square 题目连接: http://www.codeforces.com/contest/711/problem/B Description ZS the C ...
 - Codeforces Round #365 (Div. 2) A
		
Description Mishka is a little polar bear. As known, little bears loves spending their free time pla ...
 - Codeforces Round #369 (Div. 2) B. Chris and Magic Square (暴力)
		
Chris and Magic Square 题目链接: http://codeforces.com/contest/711/problem/B Description ZS the Coder an ...
 - Mishka and Divisors[CodeForces Round #365 Div.2]
		
http://codeforces.com/contest/703/problem/E 题意:给定一个最多个数的序列,从中选出最少个数的数字,使得他们的乘积是k的倍数,若有多种选择方式,输出选出数字和 ...
 - Codeforces Round #365 (Div. 2)-D  Mishka and Interesting sum(树状数组)
		
题目链接:http://codeforces.com/contest/703/problem/D 思路:看了神犇的代码写的... 偶数个相同的数异或结果为0,所以区间ans[l , r]=区间[l , ...
 - Codeforces Round #365 (Div. 2) D. Mishka and Interesting sum 离线+线段树
		
题目链接: http://codeforces.com/contest/703/problem/D D. Mishka and Interesting sum time limit per test ...
 
随机推荐
- http报文在网络中是明文传输的,所以不安全。HTtp必然来临
			
HTTP数据在网络中裸奔 HTTP明文协议的缺陷,是导致数据泄露.数据篡改.流量劫持.钓鱼攻击等安全问题的重要原因.HTTP协议无法加密数据,所有通信数据都在网络中明文“裸奔”.通过网络的嗅探设备及一 ...
 - Sina App Engine(SAE)入门教程(3)-KVDB使用
			
简介 因为传统关系型数据库在分布式环境下表现的扩展性不足等缺点,近年来NoSQL的概念渐渐成为业界关注的焦点,越来越多的技术人员也习惯于使用NoSQL数据库进行日常开发,SAE为了应对这种新需求,也进 ...
 - Hibernate学习笔记(1)
			
1 使用Hibernate (1)创建User Library,命名为HIBERNATE3,加入需要的jar (2)创建hibernate配置文件hibernate.cfg.xml, 为了便于调试最好 ...
 - Zookeeper、HBase的伪分布
			
1.Zookeeper伪分布的部署(3个节点) 所谓的“伪分布式集群”就是在一台服务器中,启动多个Zookeeper实例.“完全分布式集群”是每台服务器,启动一个Zookeeper实例. 1.1.解压 ...
 - RegexOne
			
http://regexone.com/ http://regexone.com/lesson/optional_characters? http://regexone.com/lesson/capt ...
 - Hibernate4.2.2使用Annotation配置
			
1.在hibernate官网下载hibernate-release-4.2.2.Final.zip并解压 2.新建一个java project工程(20130619_Hibernate4.2.2_An ...
 - hdu 1257 最少拦截系统(简单贪心)
			
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1257 虽然分类是dp感觉还是贪心 比较水 #include <iostream> #inclu ...
 - tomcat发布web service教程
			
这几天一直在准备找工作,自学了关于web service的一些基本的内容,也遇到了不少问题.现在就把我自己学到的知识和大家分享一下,由于是初学,所以有什么错误的地方请大家帮忙指正,感激不尽~~!! 1 ...
 - Qt之自定义界面(右下角冒泡)
			
简述 网页右下角上经常会出现一些提示性的信息,桌面软件中也比较常见,类似360新闻.QQ消息提示一样! 这种功能用动画实现起来很简单,这节我们暂时使用定时器来实现,后面章节会对动画框架进行详细讲解. ...
 - 利用改进的cca算法,进行识别
			
这个方法,很有意思,第一,不用降维:第二,跟ica做比较,竟然说比强大的ica还好: 看来,国防科大的博士,还是很牛的. <OI and fMRI Signal Separation Using ...