Chris and Road

题意:

给一个n个顶点的多边形的车,有速度v,人从0走到对面的w,人速度u,问人最快到w的时间是多少,车如果挡到人,人就不能走。

题解:

这题当时以为计算几何,所以就没做,其实真的应该认真想想的,一般cf前3题仔细想想是可以出的,其实思路很简单,如下:

题解:一共有三种情况:

①. 人以最大速度u前进时,汽车的速度很慢,任意一点都到达不了人的位置

②.人以最大速度u前行时,汽车的速度很快,在人达到之前汽车的任意一点都已经通过了y轴

③.人以最大速度u前进时,会与汽车相撞,需要调整速度躲避汽车

上面三种情况,①②两种都可以直接以最大速度u通过马路。对于第③种情况,我们可以在汽车最后一个通过y轴的点通过时行人恰好到达那个点的位置(如上图就是(0,3)),然后全速u走到终点。在过这个点之前,行人怎么变速的,我们就没必要考虑,反正他到达这个点的时间就是汽车完全通过这个点的时间,这样想来就好多了

代码:

#include <bits/stdc++.h>
using namespace std; double x, y;
int main() {
int n;
double w, v, u;
while(cin >> n >> w >> v >> u) {
bool f1 = 0, f2 = 0;
double ans = 0;
for(int i = 0; i < n; i++) {
cin >> x >> y;
if(x / v < y / u) f1 = 1;
if(x / v > y / u) f2 = 1;
ans = max(ans, x / v + (w - y) / u);
}
if(f1 && f2) printf("%.10f\n", ans);
else printf("%.10f\n", w / u);
}
return 0;
}

Codeforces Round #365 (Div. 2) Chris and Road的更多相关文章

  1. Codeforces Round #365 (Div. 2) C - Chris and Road 二分找切点

    // Codeforces Round #365 (Div. 2) // C - Chris and Road 二分找切点 // 题意:给你一个凸边行,凸边行有个初始的速度往左走,人有最大速度,可以停 ...

  2. Codeforces Round #365 (Div. 2)

    A题 Mishka and Game 水..随便统计一下就A了 #include <cstdio> #include <map> #include <set> #i ...

  3. 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 ...

  4. Codeforces Round #365 (Div. 2) A

    Description Mishka is a little polar bear. As known, little bears loves spending their free time pla ...

  5. Mishka and Divisors[CodeForces Round #365 Div.2]

    http://codeforces.com/contest/703/problem/E 题意:给定一个最多个数的序列,从中选出最少个数的数字,使得他们的乘积是k的倍数,若有多种选择方式,输出选出数字和 ...

  6. Codeforces Round #365 (Div. 2)-D Mishka and Interesting sum(树状数组)

    题目链接:http://codeforces.com/contest/703/problem/D 思路:看了神犇的代码写的... 偶数个相同的数异或结果为0,所以区间ans[l , r]=区间[l , ...

  7. Codeforces Round #365 (Div. 2) B 前缀和

    B. Mishka and trip time limit per test 1 second memory limit per test 256 megabytes input standard i ...

  8. 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 ...

  9. Codeforces Round #365 (Div. 2) D. Mishka and Interesting sum (离线树状数组+前缀xor)

    题目链接:http://codeforces.com/contest/703/problem/D 给你n个数,m次查询,每次查询问你l到r之间出现偶数次的数字xor和是多少. 我们可以先预处理前缀和X ...

随机推荐

  1. Codeforces Round #127 (Div. 2)

    A. LLPS 长度最大10,暴力枚举即可. B. Brand New Easy Problem 枚举\(n\)的全排列,按题意求最小的\(x\),即逆序对个数. C. Clear Symmetry ...

  2. nginx无法启动: libpcre.so.1/libpcre.so.0: cannot open shared object file解决办法

    NGINX启动时提示错误: /usr/local/nginx/sbin/nginx -t/usr/local/nginx/sbin/nginx: error while loading shared ...

  3. Unity坐标系

    Unity 使用的是左手坐标系

  4. cookies的理解

    设置cookie 每个cookie都是一个名/值对,可以把下面这样一个字符串赋值给document.cookie: document.cookie="userId=828"; 如果 ...

  5. 二十四种设计模式:中介者模式(Mediator Pattern)

    中介者模式(Mediator Pattern) 介绍用一个中介对象来封装一系列的对象交互.中介者使各对象不需要显式地相互引用,从而使其耦合松散,而且可以独立地改变它们之间的交互. 示例有一个Messa ...

  6. mrtg

    centos6.5-64-minimal http://oss.oetiker.ch/mrtg/doc/cfgmaker.en.htmlhttp://www.cnblogs.com/see7di/ar ...

  7. 深入认识JavaScript 中的this指针

    深入认识JavaScript 中的this指针this指针是面向对象程序设计中的一项重要概念,它表示当前运行的对象.在实现对象的方法时,可以使用this指针来获得该对象自身的引用.和传统意义的面向对象 ...

  8. 配置android模拟器

    配置android模拟器 1. 将android-sdk-windows.rar和eclipse_android.rar解压到D盘根目标下 直接将两个压缩文件解压到当前分区(D盘)即可 2. 配置环境 ...

  9. windows下做react native官方例子遇到的问题

    1.android/app/build.gradle文件中,指定了版本: compileSdkVersion 23buildToolsVersion "23.0.1" 需要在设置中 ...

  10. ORALCE 游标简单的实例

    --取简单的游标 declare cursor sp is select * from user_tables; myrecord user_tables%ROWTYPE; begin open sp ...