题目大意就是说两个人掷飞镖,飞镖在所给定的图形内就记一分,现在给定N个图形(圆、三角形和矩形),问每一次比赛(没人分别掷三次)谁赢。

 #include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <ctime>
#include <vector>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
using namespace std;
#define eps 1e-12
#define MAXN 55
#define INF 1e30
#define mem0(a) memset(a,0, sizeof(a))
#define mem1(a) memset(a,-1,sizeof(a))
double MAX(double a, double b) {return a > b ? a : b;}
double MIn(double a, double b) {return a < b ? a : b;}
typedef long long LL;
/****************************************计算几何头文件**************************************************/
struct Point{
double x,y;
Point(double x=, double y=):x(x),y(y){}
}; struct Polygon
{
Point p[MAXN];
int Size;
}; struct Circle
{
Point o;
double r;
Circle(){}
Circle(Point _o, double _r):o(_o),r(_r){}
}; Point operator + (Point A, Point B) {return Point(A.x+B.x, A.y+B.y);} Point operator - (Point A, Point B) {return Point(A.x-B.x, A.y-B.y);} Point operator * (Point A, double p) {return Point(A.x*p, A.y*p);} Point operator / (Point A, double p) {return Point(A.x/p, A.y/p);} int dcmp(double x) {
if(fabs(x) < eps) return ;
else return x < ? - : ;
} bool operator == (const Point &A, const Point &B) {
return dcmp(A.x-B.x) == && dcmp(A.y-B.y) == ;
} double Dot(Point A, Point B) { return A.x*B.x + B.y*B.y;} //点积 double Length(Point A) { return sqrt(Dot(A,A));} //向量长度 double Angle(Point A, Point B) {return acos(Dot(A,B) / Length(A) / Length(B));}//向量夹角 double cross(Point A, Point B) {return A.x*B.y - A.y*B.x;} bool crossed(Point a, Point b, Point c, Point d)//线段ab和cd是否相交
{
if(cross(a-c, d-c)*cross(b-c, d-c)<= && cross(c-a, b-a)*cross(d-a, b-a)<=)
{
return true;
}
return false;
} bool isPointOnSegent(Point p, Point s, Point e)//判断点是否在线段se上
{
double d = (p.x-s.x) * (e.x-p.x);
double a = (p.y-s.y) / (p.x-s.x);
double b = (e.y-p.y) / (e.x-p.x);
if(dcmp(d)== && dcmp(a-b)==)return true;
return false;
} int isPointInPolygon(Point p, Polygon poly)//判断点是否在多边形以内
{
int w = ;
int n = poly.Size;
for(int i=;i<n;i++)
{
if(isPointOnSegent(p, poly.p[i], poly.p[(i+)%n])) return ;//点在边上
int k = dcmp(cross(poly.p[(i+)%n]-poly.p[i], p-poly.p[i]));
int d1 = dcmp(poly.p[i].y - p.y);
int d2 = dcmp(poly.p[(i+)%n].y - p.y);
if(k > && d1 <= && d2 > ) w++;
if(k < && d2 <= && d1 > ) w--;
}
if(w != ) return ;
return ;
} /****************************************************************************************************/
struct R
{
Point a, b;
R(){}
R(Point _a, Point _b)
{
a = _a;
b = _b;
}
}r[];
struct T
{
Point a, b, c;
T(){}
T(Point _a, Point _b, Point _c) {
a = _a; b = _b; c = _c;
}
}t[];
Circle c[];
int S, N;
int cntC = , cntT = , cntR = ; int calc(double x, double y)//计算点(x, y)在图中的多少个图形内部
{
Point p = Point(x, y);
int ans = ;
for(int i=;i<cntC;i++)
{
if(Length(p-c[i].o) <= c[i].r) ans ++;
}
for(int i=;i<cntT;i++)
{
if( cross(t[i].c-t[i].a, p-t[i].a)*cross(t[i].b-t[i].a, p-t[i].a)<=
&& cross(t[i].a-t[i].b, p-t[i].b)*cross(t[i].c-t[i].b, p-t[i].b)<= ) ans ++;
}
for(int i=;i<cntR;i++)
{
if(x>=r[i].a.x&&x<=r[i].b.x && y>=r[i].a.y&&y<=r[i].b.y) ans ++;
}
return ans;
} int main()
{
char ch;double x, y, rr;
while(~scanf("%d%*c", &S))
{
cntT = cntC = cntR = ;
for(int i=;i<S;i++)
{
scanf("%c", &ch);
if(ch == 'C')
{
scanf("%lf %lf %lf%*c", &x, &y, &rr);
c[cntC++] = Circle(Point(x, y), rr);
continue;
}
else if(ch == 'T')
{
Point aa[];
for(int j=;j<;j++)
{
scanf("%lf%*c%lf%*c", &x, &y);
aa[j] = Point(x, y);
}
t[cntT++] = T(aa[],aa[],aa[]);
}
else
{
Point aa[];
for(int j=;j<;j++)
{
scanf("%lf%*c%lf%*c", &x, &y);
aa[j] = Point(x, y);
}
r[cntR++] = R(aa[], aa[]);
}
}
scanf("%d", &N);
for(int i=;i<N;i++)
{
int cntA = , cntB = ;
for(int j=;j<;j++)
{
scanf("%lf %lf", &x, &y);
cntA += calc(x, y);
}
for(int j=;j<;j++)
{
scanf("%lf %lf", &x, &y);
cntB += calc(x, y);
}
// printf("%d %d\n", cntA, cntB);
printf("%s\n", cntA > cntB ? "Bob" : (cntA == cntB ? "Tied" : "Hannah"));
}
}
return ;
}

HDU2948Geometry Darts(简单计算几何)的更多相关文章

  1. ●POJ 1556 The Doors(简单计算几何+最短路)

    ●赘述题目 10*10的房间内,有竖着的一些墙(不超过18个).问从点(0,5)到(10,5)的最短路. 按照输入样例,输入的连续5个数,x,y1,y2,y3,y4,表示(x,0--y1),(x,y2 ...

  2. 2018.07.04 POJ 2398 Toy Storage(二分+简单计算几何)

    Toy Storage Time Limit: 1000MS Memory Limit: 65536K Description Mom and dad have a problem: their ch ...

  3. 2018.07.03 BZOJ 1007: [HNOI2008]水平可见直线(简单计算几何)

    1007: [HNOI2008]水平可见直线 Time Limit: 1 Sec Memory Limit: 162 MB Description 在xoy直角坐标平面上有n条直线L1,L2,-Ln, ...

  4. 2018.07.04 POJ 1654 Area(简单计算几何)

    Area Time Limit: 1000MS Memory Limit: 10000K Description You are going to compute the area of a spec ...

  5. 2018.07.04 POJ 3304 Segments(简单计算几何)

    Segments Time Limit: 1000MS Memory Limit: 65536K Description Given n segments in the two dimensional ...

  6. 2018.07.03 POJ 2318 TOYS(二分+简单计算几何)

    TOYS Time Limit: 2000MS Memory Limit: 65536K Description Calculate the number of toys that land in e ...

  7. 2018.07.03 POJ 2653 Pick-up sticks(简单计算几何)

    Pick-up sticks Time Limit: 3000MS Memory Limit: 65536K Description Stan has n sticks of various leng ...

  8. Gym 101917 E 简单计算几何,I 最大流

    题目链接 https://codeforces.com/gym/101917 E 题意:给定一个多边形(n个点),然后逆时针旋转A度,然后对多边形进行规约,每个点的x规约到[0,w]范围内,y规约到[ ...

  9. 洛谷 - P1355 - 神秘大三角 - 简单计算几何

    https://www.luogu.org/problemnew/show/P1355 判断一个点和三角形的位置关系,最简单的思路就是用向量. 首先排除掉和三角形顶点重合的情况. 把三角形设计成一个首 ...

随机推荐

  1. poj 1659 Frogs' Neighborhood(出入度、可图定理)

    题意:我们常根据无向边来计算每个节点的度,现在反过来了,已知每个节点的度,问是否可图,若可图,输出一种情况. 分析:这是一道定理题,只要知道可图定理,就是so easy了  可图定理:对每个节点的度从 ...

  2. PS:WINRAR制作32位安装程序和64位安装程序选项

    32位 64位

  3. 《Write Optimized B-Trees》读书报告

    论文原作者:Goetz Graefe, Microsoft.我读完这篇论文后颇有收获,所以写了一篇论文报告,旨在更精炼准确地阐述论文核心思想. 摘要:论文提出了一种方法,这种方法可以优化B树索引写性能 ...

  4. liux环境下配置jdk

    大家都知道,现在JAVA的发展可谓是如日中天,它覆盖面非常广泛,小到个人PC,大到商业应用都能见到它的身影.以前它是由SUN公司来维护的,现在已经归属到甲骨文旗下了. 今天我们来学习一下Java JD ...

  5. Symfony2学习笔记之数据校验

    校验在web应用程序中是一个常见的任务.数据输入到表单需要被校验.数据在被写入数据库之前或者传入一个webservice时也需要被校验. Symfony2 配备了一个Validator 组件,它让校验 ...

  6. PHP中的cookie

    第一次设置后,第二次访问才生效,决绝办法可以用js跳转首页实现刷新. 1.创建/更新cookie setCookie($cookieName,$value,time()+秒数): 例子:创建一个coo ...

  7. Informatica9.6.1在Linux Red Hat 5.8上安装遇到的有关问题整理_3

    3.Repository Service启动后的页面编码问题 1)错误信息: 2)原因分析及解决步骤 原因分析: informatica产品安装背后AdminConsole的Code page默认为U ...

  8. android 深入研究ratingbar自定义

    http://blog.csdn.net/rain_butterfly/article/details/22892879

  9. Ajax轮询以及Comet模式—写在Servlet 3.0发布之前(转)

    2008 年的夏天,偶然在网上闲逛的时候发现了 Comet 技术,人云亦云间,姑且认为它是由 Dojo 的 Alex Russell 在 2006 年提出.在阅读了大量的资料后,萌发出写篇 blog ...

  10. [python]使用pexpect模块进行批量scp

    #!/usr/bin/env python# -*- coding: utf-8 -*- #wangxiaofei #awcloud自动化测试 import time,osimport threadi ...