思路:将飞机看成不动的,然后枚举时间看点是否在多边形内部。

#include<bits/stdc++.h>
#define LL long long
#define fi first
#define se second
#define mk make_pair
#define PII pair<int, int>
#define PLI pair<LL, int>
#define ull unsigned long long
using namespace std; const int N = + ;
const int inf = 0x3f3f3f3f;
const LL INF = 0x3f3f3f3f3f3f3f3f;
const int mod = 1e9 + ;
const double eps = 1e-; struct Point {
double x, y;
Point(double x = , double y = ) : x(x), y(y) { } };
typedef Point Vector;
int dcmp(double x) {
if(fabs(x) < eps) return ;
else return x < ? - : ;
}
Point operator + (Vector A, Vector B) {return Point(A.x + B.x, A.y + B.y);}
Point operator - (Vector A, Vector B) {return Point(A.x - B.x, A.y - B.y);}
Point operator * (Vector A, double p) {return Point(A.x * p, A.y * p);}
Point operator / (Vector A, double p) {return Point(A.x / p, A.y / p);}
bool operator < (const Vector &A, const Vector &B) {return A.y < B.y || (A.y == B.y && A.x < B.x);}
bool operator == (const Vector &A, const Point &B) {return dcmp(A.x - B.x) == && dcmp(A.y - B.y) == ;}
double Dot(Vector A, Vector B) {return A.x * B.x + A.y * B.y;}
double Length(Vector A) {return sqrt(Dot(A, A));}
double Angle(Vector A, Vector B) {return acos(Dot(A, B) / Length(A) / Length(B));}
double Cross(Vector A, Vector B) {return A.x * B.y - A.y * B.x;}
double Area2(Point A, Point B, Point C) {return Cross(B - A, C - A);} double v, b, g;
Point p[N];
int n; bool isPointOnSegment(const Point &p, const Point &a1, const Point &a2)
{
if(dcmp(Cross(a1-p,a2-p))) return ;
else if(dcmp(p.x-min(a1.x,a2.x))>=&&dcmp(p.x-max(a1.x,a2.x))<=
&&dcmp(p.y-min(a1.y,a2.y))>=&&dcmp(p.y-max(a1.y,a2.y))<=) return ;
else return ;
} int isPointInPolygon(Point p, Point *poly, int n) {
int wn = ;
for(int i = ; i < n; i++) {
if(isPointOnSegment(p, poly[i], poly[(i+)%n])) return -; //在边界上
int k = dcmp(Cross(poly[(i+)%n]-poly[i], p-poly[i]));
int d1 = dcmp(poly[i].y-p.y);
int d2 = dcmp(poly[(i+)%n].y-p.y);
if(k> && d1<= && d2>) wn++;
if(k< && d2<= && d1>) wn--;
}
if(wn != ) return ; //内部
return ; //外部
} bool check(double t) {
Point pos = Point(-v*t, 0.5*-g*t*t + b*t);
if(isPointInPolygon(pos, p, n) == ) return true;
return false;
} int main() {
while(scanf("%lf%lf%lf", &v, &b, &g) != EOF) {
if(v < eps && b < eps && g < eps) break;
scanf("%d", &n);
for(int i = ; i < n; i++)
scanf("%lf%lf", &p[i].x, &p[i].y);
double ans = -;
for(double t = ; t <= ; t += 0.001) {
if(check(t)) {
ans = t;
break;
}
}
if(ans < ) puts("Miss!");
else printf("%.2f\n", ans);
}
return ;
} /*
ŝ
*/

HDU - 4458 计算几何判断点是否在多边形内的更多相关文章

  1. hrbustoj 1429:凸多边形(计算几何,判断点是否在多边形内,二分法)

    凸多边形 Time Limit: 2000 MS    Memory Limit: 65536 K Total Submit: 130(24 users)   Total Accepted: 40(1 ...

  2. hrbustoj 1306:再遇攻击(计算几何,判断点是否在多边形内,水题)

    再遇攻击 Time Limit: 1000 MS    Memory Limit: 65536 K Total Submit: 253(37 users)   Total Accepted: 56(2 ...

  3. zoj 1081:Points Within(计算几何,判断点是否在多边形内,经典题)

    Points Within Time Limit: 2 Seconds      Memory Limit: 65536 KB Statement of the Problem Several dra ...

  4. 百度地图 判断marker是否在多边形内

    昨天画了圆形,判marker是否存在圆形内.今天来画多边形,判断marker在多边形内. 需要引入一个js      <script type="text/javascript&quo ...

  5. C# 判断点是否在多边形内

    /// <summary>/// 判断点是否在多边形内/// </summary>/// <param name="pnt">点</par ...

  6. [zoj] 1081 Points Within || 判断点是否在多边形内

    原题 多组数据. n为多边形顶点数,m为要判断的点数 按逆时针序给出多边形的点,判断点是否在多边形内,在的话输出"Within",否则输出"Outside" / ...

  7. PHP 判断点是否在多边形内

    如何判断一个点是否在一个多边形内,何时会用到这个场景. 我们就模拟一个真是场景.我们公司是快递公司,在本地区域有6个分点.每个分点有3-5个工人负责附近的快递派遣发送,所以根据每个点的服务区域我们就能 ...

  8. Geos判断点是否在多边形内

    使用的geo版本是3.5.1 #include <iostream> #include "geos.h" using namespace std; GeometryFa ...

  9. POJ 1584 A Round Peg in a Ground Hole[判断凸包 点在多边形内]

    A Round Peg in a Ground Hole Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 6682   Acc ...

随机推荐

  1. bzoj千题计划141:bzoj3532: [Sdoi2014]Lis

    http://www.lydsy.com/JudgeOnline/problem.php?id=3532 如果没有字典序的限制,那么DP拆点最小割即可 加上字典序的限制: 按c从小到大枚举最小割边集中 ...

  2. SQL - 查询某一字段值相同而另一字段值最大的记录

    有时需要以某一字段作为分组,筛选每一组的另一字段值最大(或最小)的记录.例如,有如下表 app,存储了 app 的 ID.名称.版本号等信息.现在要筛选出每个 app 版本最大的记录. 方法一 SEL ...

  3. 安装rqalpha的日志

    安装rqalpha的日志 用anaconda的控制台命令: pip install -i https://pypi.tuna.tsinghua.edu.cn/simple rqalpha rqalph ...

  4. java 获得字符串中最大重复子串长度

    参考:http://blog.csdn.net/csdn_yaobo/article/details/50338025 要找一串字符串中,重复的字串长度,.例如ABCX1&ABC,中ABC重复 ...

  5. 50、多线程创建的三种方式之实现Runnable接口

    实现Runnable接口创建线程 使用Runnable创建线程步骤: package com.sutaoyu.Thread; //1.自定义一个类实现java.lang包下的Runnable接口 cl ...

  6. Python练习-生成器表达式-筛选与运算

    # 编辑者:闫龙 l = [10, 2, 3, 4, 5, 6, 7] l1 = [int(i)**2 for i in l] # 得到一个新列表l1,新列表中每个元素是l中对应每个元素值的平方 pr ...

  7. 关于Python编码问题小记

    Python编码问题小记: 引子: 最近在复习redis,当我在获取redis的key的时候,redis 存储英文和汉字下面这个样子的,我知道汉字是用16进制的UTF-8编码了,然后突然很想搞清楚字符 ...

  8. 【bzoj题解】题解传送门

    如题,题解传送门: 1001 1008 1012

  9. ubuntu 18.04 安装 flash

    下载源码包, 解压 sudo cp Downloads/flash_player_npapi_linux.x86_64/libflashplayer.so /usr/lib/mozilla/plugi ...

  10. git fetch 命令

    git fetch命令用于从另一个存储库下载对象和引用. 使用语法 git fetch [<options>] [<repository> [<refspec>…] ...