题意:有一个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. 西瓜书概念整理(chapter 1-2)熟悉机器学习术语

    括号表示概念出现的其他页码, 如有兴趣协同整理,请到issue中认领章节 完整版见我的github:ahangchen 觉得还不错的话可以点个star ^_^ 第一章 绪论 Page2: 标记(lab ...

  2. element table固定表头,表的高度自适应解决方法

    主要是通过在mounted生命周期中,改变tableHeight的值,来让表格的高度自适应. 标签: <el-table ref="table" :data="ta ...

  3. Azure VM复制

    目前Azure上复制VM可以有多种方法: 1 创建User Image,可以快速复制多台VM,但目前托管磁盘只支持Generalized的模式,需要对User和配置进行重置. 2 从VHD或托管磁盘复 ...

  4. phpBB安装

    要测试一个网站的安全性,不得不安装一个网站.常用的Hello World!不行了,找了个phpBB安装.非常方便,记录一下安装过程. 下载phpBB 下载地址:http://tianjin.mycod ...

  5. Attribute注解(用于判断权限)

    一  Attribute原理: Attribute注解,是附加上方法.属性.类等上面的标签,可以通过方法的GetCustomAttribute获得粘贴的这个Attribute对象通过反射调用到粘贴到属 ...

  6. commandLink/commandButton/ajax backing bean action/listener method not invoked (转)

    Whenever an UICommand component fails to invoke the associated action method or an UIInputelement fa ...

  7. 【转】IMSI和IMEI

    国际移动客户识别码(International Mobile Subscriber Identification Number) 为了在无线路径和整个GSM移动通信网上正确地识别某个移动客户,就必须给 ...

  8. weex和vue开发环境配置详解(配置系统变量等等)

    本文详细讲解如何搭建weex和vue开发环境 安装java 现在java安装包,网上的安装包都是国外的,很难下载下来 就用这个链接下载,亲测无毒,http://www.wmzhe.com/soft-3 ...

  9. java 多线程系列基础篇(九)之interrupt()和线程终止方式

    1. interrupt()说明 在介绍终止线程的方式之前,有必要先对interrupt()进行了解.关于interrupt(),java的djk文档描述如下:http://docs.oracle.c ...

  10. Shell编程进阶 1.5 if逻辑判断

    逻辑判断 vim if.sh #!/bin/bash ## ## a= ] then echo "a>3" fi sh if.sh a>3 vim if2.sh #!/ ...