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 #125 (Div. 2)

    A. Hexadecimal's theorem 三个数没有限制,直接输出\(0\ 0\ n\). B. Special Olympics 分包含和外离情况,包含分2种情况. C. About Bac ...

  2. 1-1 Windows应用程序的特点

    主要内容:介绍Windows应用程序的特点,并附加了消息和事件的一些区别 //以后该分类中字体均采用 隶书 4(14pt) 1. 面向对象 <1>针对Windows应用本身,如记事本界面, ...

  3. Java继承_接口练习题

    1.创建一个名称为StaticDemo的类,并声明一个静态变量和一个普通变量.对变量分别赋予10和5的初始值.在main()方法中输出变量值. 编写代码如下: package org.hanqi.pr ...

  4. linux下crontab定时执行本地脚本和定时访问指定url

    https://my.oschina.net/u/2487410/blog/683308 使用linux curl命令讲解:http://www.linuxdiyf.com/linux/2800.ht ...

  5. freeswitch 挂断前执行脚本

    通道变量名 api_hangup_hook 介绍在挂断时执行指定API命令 示例 <action application="set" data="api_hangu ...

  6. webstorm修改文件,webpack-dev-server不自动编译刷新的解决办法

    webstorm设置中,"Settings"--"Appearance & Behavior"--"System Settings" ...

  7. discuz 发布分类信息,能不能设置单版块去掉“发帖子”(默认点发帖后为自定义的默认分类信息模版)

    http://www.discuz.net/forum.php?mod=viewthread&tid=3365198&page=1#pid26849156

  8. git教程,待学习

    http://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000 Git教程: Git简介Git的诞 ...

  9. 微信 JSSDK .NET版

    /*因为官方 微信 JSSDK 只有PHP java版本的 我自己照着PHP的翻译过来的,可供参考.欢迎指正*/ [csharp] view plaincopy在CODE上查看代码片派生到我的代码片 ...

  10. Redis配制说明

    配置文件参数说明:  1. Redis默认不是以守护进程的方式运行,可以通过该配置项修改,使用yes启用守护进程     daemonize no 2. 当Redis以守护进程方式运行时,Redis默 ...