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 ...
随机推荐
- mysql级联删除更新
首先,目前在产品环境可用的MySQL版本(指4.0.x和4.1.x)中,只有InnoDB引擎才允许使用外键,所以,我们的数据表必须使用InnoDB引擎. 下面,我们先创建以下测试用数据库表: CREA ...
- python基础 - 文件读写
完成功能: 从指定位置读文件到控制台 #! /usr/bin/python # coding=utf- 方法一. try: f = open ('/root/python/file/001.txt', ...
- Retrofit2 源码解析
原文链接:http://bxbxbai.github.io/2015/12/13/retrofit2-analysis/ 公司里最近做的项目中网络框架用的就是Retrofit,用的多了以后觉得这个框架 ...
- Intellij Idea 创建EJB项目入门(一)
相关软件: 1.JBoss(jboss-as-7.1.1.Final):http://jbossas.jboss.org/downloads 2.Intellij IDEA 13.02 3.JDK 1 ...
- Java中ArrayList和LinkedList区别
ArrayList和LinkedList的大致区别如下:1.ArrayList是实现了基于动态数组的数据结构,LinkedList基于链表的数据结构. 2.对于随机访问get和set,ArrayLis ...
- WIN7 64位系统搭建WINCE6.0系统遇到的问题
WIN7 64位系统搭建WINCE6.0系统遇到的问题 安装顺序如下: .先装Visual Studio2005: .安装Visual Studio2005 Service Pack 1: .安装Vi ...
- HDU 4675 GCD of Sequence(容斥)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4675 题意:给出n,m,K,一个长度为n的数列A(1<=A[i]<=m).对于d(1< ...
- 转 intent常用功能
1.从google搜索内容Intent intent = new Intent();intent.setAction(Intent.ACTION_WEB_SEARCH);intent.putExtra ...
- Oracle的rownum原理和使用(整理几个达人的帖子)
整理和学习了一下网上高手关于rownum的帖子: 参考资料: http://tech.ddvip.com/2008-10/122490439383296.html 和 http://tenn.jav ...
- poi2012完成
终于完成了(2798是我cheat的……),感觉poi的题好锻炼智商…… 截图留念,题解见博客中对应题号的解题报告