关闭

HDOJ 5563 Clarke and five-pointed star (判断五个点组成的是否为正五角星)

596人阅读 评论(5) 收藏 举报
分类:

Clarke and five-pointed star

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 420    Accepted Submission(s): 227


Problem Description
Clarke is a patient with multiple personality disorder. One day, Clarke turned into a learner of geometric.
When he did a research with polygons, he found he has to judge if the polygon is a five-pointed star at many times. There are 5 points on a plane, he wants to know if a five-pointed star existed with 5 points given.
 

Input
The first line contains an integer T(1T10), the number of the test cases.
For each test case, 5 lines follow. Each line contains 2 real numbers xi,yi(109xi,yi109), denoting the coordinate of this point.
 

Output
Two numbers are equal if and only if the difference between them is less than104.
For each test case, print Yes if they can compose a five-pointed star. Otherwise, print No. (If 5 points are the same, print Yes. )
 

Sample Input
2 3.0000000 0.0000000 0.9270509 2.8531695 0.9270509 -2.8531695 -2.4270509 1.7633557 -2.4270509 -1.7633557 3.0000000 1.0000000 0.9270509 2.8531695 0.9270509 -2.8531695 -2.4270509 1.7633557 -2.4270509 -1.7633557
 

Sample Output
Yes No
Hint
题意:给你5个点,求这5个点能不能连成一个正五角星 思路:见每个点都连起来会发现,会组成一个五边形,而正五角星组成的是正五边形,所一说此题就转化为判断是否 能组成正五边形直接枚举距离,正多边形个点之间的连线中边长一定是最短的那条边,所以我们只需要查看最短边数 量是否等于5就可以判断是不是正五边形,也就能判断能不能组成正五角星。需要注意的是精度问题。可能这道题数 据有点弱,窝水了过去,正式的应该是先求凸包,然后在判断,但是可能因为精度问题水了过去。。 类似的题有:点击打开链接 ac代码:  
<pre name="code" class="cpp">#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stack>
#include<iostream>
#include<algorithm>
#define fab(a) (a)>0?(a):(-a)
#define LL long long
#define MAXN 1000010
#define mem(x) memset(x,0,sizeof(x))
#define INF 0xfffffff 
using namespace std;
struct s
{
	double x,y;
}a[10];
int v[10][10];
double dis[1000];
double fun(s aa,s bb)
{
	return sqrt((aa.x-bb.x)*(aa.x-bb.x)+(aa.y-bb.y)*(aa.y-bb.y));
}
int main()
{
	int t,i,j;
	scanf("%d",&t);
	while(t--)
	{
		for(i=0;i<5;i++)
		scanf("%lf%lf",&a[i].x,&a[i].y);
		mem(v);
		int k=0;
		double mi=1.0*INF;
		for(i=0;i<5;i++)
		{
			for(j=i+1;j<5;j++)
			{
				if(v[i][j]||v[j][i])
				continue;
				dis[k]=fun(a[i],a[j]);
				mi=min(mi,dis[k]);
				v[i][j]=1; 
				k++;
			}
		}
		int cnt=0;
		for(i=0;i<k;i++)
		{
			if(dis[i]-mi<=1e-4)//精度问题
			cnt++;
		}
		if(cnt==5)
		printf("Yes\n");
		else
		printf("No\n");
	}
	return 0;
}




 
0
0
查看评论

hdoj 5563 Clarke and five-pointed star 【判断五角星】

Clarke and five-pointed star            Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 6553...
  • chenzhenyu123456
  • chenzhenyu123456
  • 2015-12-05 21:38
  • 250

hdoj Clarke and five-pointed star 5563 (判断能否组成五角星)

Clarke and five-pointed star Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s):...
  • yanghui07216
  • yanghui07216
  • 2015-11-25 22:19
  • 201

HDOJ 5563 Clarke and five-pointed star

Clarke and five-pointed star Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submissio...
  • qq_34542903
  • qq_34542903
  • 2016-10-13 16:08
  • 117

CodeForces 549D (暴力、模拟)

D. Haar Features time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output The first algorith...
  • aaaaacmer
  • aaaaacmer
  • 2015-07-18 18:33
  • 548

HDU 5563 Clarke and five-pointed star

Problem Description Clarke is a patient with multiple personality disorder. One day, Clarke turned into a learner of geometric. When he did a rese...
  • jtjy568805874
  • jtjy568805874
  • 2015-11-29 22:59
  • 204

HDOJ 5563 Clarke and five-pointed star(枚举)

Clarke and five-pointed star Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(...
  • zwj1452267376
  • zwj1452267376
  • 2015-11-14 22:44
  • 271

HDU 5563 Clarke and five-pointed star(判断正五边形)

问题描述 克拉克是一名人格分裂患者。某一天克拉克分裂为一个几何学习者,在研究多边形。 在研究某一个多边形的时候,克拉克发现他多次遇到判断5个点是否能组成一个五角星的问题,在这里,这5个点分别代表五角星的五个顶点(顶角上的点)。于是他跑来想你求助,让你写出一个程序快速判定。即对于给出的5个点,判断这...
  • h1021456873
  • h1021456873
  • 2015-11-17 23:57
  • 218

HDU 5563 Clarke and five-pointed star(暴力)

Clarke and five-pointed star Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 472 Accepted Subm...
  • Sterben_Da
  • Sterben_Da
  • 2015-11-18 11:04
  • 246

hdu 5563 Clarke and five-pointed star(几何)

题目链接:hdu 5563 Clarke and five-pointed star代码#include <cstdio> #include <cstring> #include <cmath> #include <algorithm>using na...
  • u011328934
  • u011328934
  • 2015-11-16 18:10
  • 396

hdoj5563Clarke and five-pointed star【判断五角星】

Clarke and five-pointed star Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(...
  • R1986799047
  • R1986799047
  • 2015-11-30 20:49
  • 302
    时刻记住--never give up
    人生如棋,吾愿为卒,吾行虽慢,谁曾见吾后退半步!
    个人资料
    • 访问:211552次
    • 积分:9034
    • 等级:
    • 排名:第2483名
    • 原创:723篇
    • 转载:3篇
    • 译文:0篇
    • 评论:29条