题意:有一个n边形的汽车向以速度v向x轴负方向移动,给出零时时其n个点的坐标。并且有一个人在(0,0)点,可以以最大速度u通过w宽的马路,到达(0,w)点。现在要求人不能碰到汽车,人可以自己调节速度。问人到达马路对面的最小时间是多少?

析:这个题是一个简单的分类讨论,很明显只有两种情况,第一种,直接到达w,不会被车撞到,答案就是w/u,

第二种是切着车过去,或者是等车过去再过去,只要枚举车的每个顶点,找到最后通过y轴的点就好,或者根本不会与车相切。

代码如下:

#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <cstring>
#include <set>
#include <queue>
#include <algorithm>
#include <vector>
#include <map>
#include <cctype>
#include <cmath>
#include <stack>
#include <sstream>
#define debug() puts("++++");
#define gcd(a, b) __gcd(a, b)
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define freopenr freopen("in.txt", "r", stdin)
#define freopenw freopen("out.txt", "w", stdout)
using namespace std; typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> P;
const int INF = 0x3f3f3f3f;
const LL LNF = 1e17;
const double inf = 0x3f3f3f3f3f3f;
const double PI = acos(-1.0);
const double eps = 1e-8;
const int maxn = 2e5 + 10;
const int mod = 1000000007;
const int dr[] = {-1, 0, 1, 0};
const int dc[] = {0, 1, 0, -1};
const char *de[] = {"0000", "0001", "0010", "0011", "0100", "0101", "0110", "0111", "1000", "1001", "1010", "1011", "1100", "1101", "1110", "1111"};
int n, m;
const int mon[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int monn[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
inline bool is_in(int r, int c){
return r >= 0 && r < n && c >= 0 && c < m;
} int main(){
int w, u, v;
scanf("%d %d %d %d", &n, &w, &v, &u);
bool ok = true;
double ans = 0.0;
for(int i = 0; i < n; ++i){
int x, y;
scanf("%d %d", &x, &y);
double t1 = x * 1.0 / v;
double t2 = y*1.0 / u;
if(t1 < t2) ok = false;
ans = max(ans,t1 + (w-y)*1.0 / u);
}
if(ok) printf("%.6f\n", w*1.0/u);
else printf("%.6f\n", max(ans, w*1.0/u));
return 0;
}

  

CodeForces 703C Chris and Road (简单几何)的更多相关文章

  1. CodeForces 703C Chris and Road

    数学,递推. 不知道有没有更加神奇的做法,我是这样想的: 首先,如果多边形完全在$y$轴左侧,那么答案为$\frac{w}{u}$. 剩下的情况就要先判断是否能在车开过之前跑过去,如果跑不过去,要在车 ...

  2. codeforces 394E Lightbulb for Minister 简单几何

    题目链接:点我点我 题意:给定n个点. 以下n行给出这n个点坐标. 给定m个点,以下m行给出这m个点坐标. 这m个点是一个凸包,顺时针给出的. 问:在凸包上随意找一个点(x, y) 使得这个点距离n个 ...

  3. Codeforces Round #365 (Div. 2) Chris and Road

    Chris and Road 题意: 给一个n个顶点的多边形的车,有速度v,人从0走到对面的w,人速度u,问人最快到w的时间是多少,车如果挡到人,人就不能走. 题解: 这题当时以为计算几何,所以就没做 ...

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

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

  5. Codeforces 935 简单几何求圆心 DP快速幂求与逆元

    A #include <bits/stdc++.h> #define PI acos(-1.0) #define mem(a,b) memset((a),b,sizeof(a)) #def ...

  6. 暑假练习赛 003 B Chris and Road

    B - Chris and Road Crawling in process... Crawling failed Time Limit:2000MS     Memory Limit:262144K ...

  7. cf703C Chris and Road

    C. Chris and Road time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...

  8. Codeforces 828B Black Square(简单题)

    Codeforces 828B Black Square(简单题) Description Polycarp has a checkered sheet of paper of size n × m. ...

  9. Python下opencv使用笔记(二)(简单几何图像绘制)

    简单几何图像一般包含点.直线.矩阵.圆.椭圆.多边形等等.首先认识一下opencv对像素点的定义. 图像的一个像素点有1或者3个值.对灰度图像有一个灰度值,对彩色图像有3个值组成一个像素值.他们表现出 ...

随机推荐

  1. vue-cli 脚手架项目-package.json

    使用vue-cli脚手架新建的项目中,含有package.json. package.json是npm的配置文件,里面设定了脚本以及项目依赖的库. npm run dev 这样的命令就写在packag ...

  2. 开发mis系统用到的技术

    1. b/s架构:就broser/server,浏览器/服务器的说法.服务器端要运行tomcat,提供链接数据库服务供java代码读写数据,这个可以在eclipse中配置运行.浏览器则解释jsp或ht ...

  3. javascript之面试题精讲

    from:http://blog.csdn.net/q121516340/article/details/51332454 1,检测数组的几种方式: Array.isArray(); es5 toSt ...

  4. 七、python沉淀之路--集合

    一. 1.字符串转集合 s = 'hello' se = set(s) print(se) {'e', 'o', 'h', 'l'} 2.列表转集合 l1 = ['hello','python','n ...

  5. hadoop完全分布式文件系统集群搭建

    一.准备工作: 1.找3台以上的主机(因为HDFS文件系统中保存的文件的blocak在datanode中至少要有3份或3份以上的备份,备份不能放于同一个机架上,更不能放于同一台主机上),我这里使用的是 ...

  6. C++对C语言的拓展(1)—— 引用

    1.变量名 变量名实质上是一段连续存储空间的别名,是一个标号(门牌号): 通过变量来申请并命名内存空间: 通过变量的名字可以使用内存空间. 2.引用的概念 变量名,本身是一段内存的引用,即别名(ali ...

  7. 如何测试远端TCP和UDP端口是否开放

    项目遇到问题时首先排查网络是否正常是一个重要的方面.遇到很多次,同事找我解决问题,最后发现却是IP或端口不通的问题.然而就是这么个简单的问题,对方却花费了甚至一天的时间排查原因. 现在大部分项目都是用 ...

  8. spark gateway引发:跟踪Cloudera安装服务异常日志跟踪

    spark gateway是用于接收cloudera管理的应用:可以上报数据,不影响正常使用.启动gateway失败,我觉得可能是因为配置问题? 这个问题可能比较深,因为我通过查看日志(clouder ...

  9. python模块导入的问题

    从模块导入函数时,通常可以使用 import somemodule 或者 from somemodule import somefunction 或者 from somemodule import s ...

  10. python3小例子:scrapy+mysql

    https://blog.csdn.net/u010151698/article/details/79371234