码迷,mamicode.com
首页 > 其他好文 > 详细

NYOJ 1165 just a problem【计算几何】

时间:2015-02-16 18:25:25      阅读:152      评论:0      收藏:0      [点我收藏+]

标签:


题目链接


 


 

#include<stdio.h>
#include<math.h>

struct point
{
	double x;
	double y;
}circle,a,b,c,d,temp;

double r;

double dis(point &a,point &b)
{
	return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}

int main()
{
	int s,t;
	scanf("%d",&s);
	while(s--)
	{
		scanf("%lf%lf%lf",&circle.x,&circle.y,&r);
		scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&a.x,&a.y,&b.x,&b.y,&c.x,&c.y,&d.x,&d.y);
		if(a.x > c.x)
		{
			temp=a;
			a=c;
			c=temp;
		}
		if(dis(a,circle)<r && dis(b,circle)<r && dis(c,circle)<r && dis(d,circle)<r)
		{
			printf("No!\n");
			continue;
		}
		if(circle.x >= a.x && circle.x <= c.x)
		{
			if(fabs(circle.y - a.y) <= r || fabs(circle.y - c.y) <= r)
			{
				printf("Yes!\n");
				continue;
			}
		}
		if((circle.y >= a.y && circle.y <= b.y) || (circle.y >= b.y && circle.y <= a.y))
		{
			if(fabs(circle.x - a.x) <= r || fabs(circle.x - c.x) <= r)
			{
				printf("Yes!\n");
				continue;
			}
		}
		if(dis(a,circle)<=r || dis(b,circle)<=r || dis(c,circle)<=r || dis(d,circle)<=r)
		{
			printf("Yes!\n");
			continue;
		}
		printf("No!\n");
	}
	return 0;
}


 

http://blog.csdn.net/sunrain_chy/article/details/9492801

 

NYOJ 1165 just a problem【计算几何】

标签:

原文地址:http://blog.csdn.net/qq_16767427/article/details/43853271

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!