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 ...
随机推荐
- 从一点儿不会开始——Unity3D游戏开发学习(二) ——GUI控件之Button
一些废话 我在上一篇“一点儿不会”的系列随笔中说大概一周会发个2~3篇关于Unity的学习笔记.可这就两周过去了,我还停留在一篇的进度上,主要是这两周发生了一些事情导致我更新缓慢.其实截至目前为止,上 ...
- 前端必杀技之Javascript 第1天
学习了javascript基本语法和使用DOM进行简单操作 1.引用javascript方法: a.在<script></script>标签中加入js代码,如: <s ...
- Android:修改版本
修改AndroidManifest.xml下的Version即可 <uses-sdk android:minSdkVersion="14" android:targetSdk ...
- Photoshop:制作金属质感-不锈钢纹理
效果图 过程: 1.滤镜->渲染->云彩 2.滤镜->模糊->高斯模糊 3.滤镜->杂色->添加杂色 ,数量10 4.滤镜->模糊->径向模糊 5.滤镜 ...
- navigationbar的一些设置记录
1.设置navigationbar背景颜色 [[UINavigationBar appearance] setBarTintColor:[UIColor blackColor]]; PS:如果颜色不对 ...
- C#获取ip的示例
界面 using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using ...
- 循环中不要放入openSession()
for(Shop s:list) { System.out.println(s.getName()); String sql="select shopId,sum(ele_bank+ele_ ...
- Codeforces 379D - New Year Letter
原题地址:http://codeforces.com/contest/379/problem/D 题目大意:给出一种生成字符串的方法 s[k] = s[k - 2] + s[k - 1],其中加法意为 ...
- 装个Redmine真是麻烦啊
弄个大半天终于看到这个界面出来了,不容易啊
- BZOJ3105: [cqoi2013]新Nim游戏
题解: 线性基?类似于向量上的基底. 此题题解戳这里:http://blog.csdn.net/wyfcyx_forever/article/details/39477673 代码: #include ...