题目大意就是说两个人掷飞镖,飞镖在所给定的图形内就记一分,现在给定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. 代码记录:使用Aforge.net让视频图像反转180度

    private void CameraConn() { videoSource = new VideoCaptureDevice(videoDevices[tscbxCameras.SelectedI ...

  2. POJ 1201 Intervals (差分约束系统)

    题意 在区间[0,50000]上有一些整点,并且满足n个约束条件:在区间[ui, vi]上至少有ci个整点,问区间[0, 50000]上至少要有几个整点. 思路 差分约束求最小值.把不等式都转换为&g ...

  3. android studio 加载第三方类库

    以引入Xutil包为例 1. 将Xutil包导入到module的libs目录下 2. File->project structure 还有一种方法是在libs目录下右键点击Add as libr ...

  4. ecshop 用户名和邮箱都能登陆

    1.打开/includes/modules/integrates/integrate.php文件,并找到下面代码 if ($this->check_user($username, $passwo ...

  5. SqlDataAdapter的update方法

    公司项目需要,需要将旧数据升级.所谓的旧数据指密码,密码经过了加密处理,但是可逆的.现将加密算法进行了更新,因此需要同步处理系统中已有的旧数据. 所有的数据存储在一个表中,简单的说是数据批量更新.自动 ...

  6. 分享15款为jQuery Mobile定制的插件

    jQuery Mobile 1.0 已经发布了, 做为jQuery的移动设备类库, 并且依靠着jQuery这个及其受欢迎的类库,必将带给大家不一样的使用体验,基于jQuery Mobile的插件开发必 ...

  7. [禅悟人生]"执著"是自缚的茧

    宋代苏东坡和佛印禅师是好朋友,他们习惯拿对方开玩笑.有一天,苏东坡到金山寺和佛印禅师打坐参禅,苏东坡觉得身心通畅,于是问禅师道:“禅师!你看我坐的样子怎么样?” “好庄严,像一尊佛!” 苏东坡听了非常 ...

  8. [Everyday Mathematic]20150212 求 $(\cos x+2)(\sin x+1)$ 的最大值

    设 $$\bex t=\tan \frac{x}{2}, \eex$$ 则 $$\bex \cos x=\frac{1-t^2}{1+t^2},\quad \sin x=\frac{2t}{1+t^2 ...

  9. location.hash来保持页面状态

    /*本例是为了在客户端页面返回时保存状态,采用hash值记录的模式,为了使用方便所写的存取hash值的库,时间仓促,望指出错误.*/var pageStateHash = { hashArray: [ ...

  10. android 性能优化大纲

    性能优化系列 分为三个部分:视图篇 逻辑篇  和代码规范篇 . ------2016/9/6  视图篇      主要涵盖视图树层级优化.自定义视图.图片优化,常用布局性能缺陷等多个方面 .把平常经常 ...