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 Submission(s): 249


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 than 104 .
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

Source


#include <cstdio>
#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std;
double length[5][5];
double point[5][2];
const double MIN=1e-4;
int main(){
	int t,i,j;
	scanf("%d",&t);
	while(t--){
		bool ok=1;
		for(i=0;i<5;i++)
			scanf("%lf%lf",&point[i][0],&point[i][1]);
		for(i=0;i<5;i++){
			for(j=0;j<5;j++){
				if(i==j){
					length[i][j]=0.0;
					continue;
				}				  
				length[i][j]=(point[i][0]-point[j][0])*
				(point[i][0]-point[j][0])+(point[i][1]-point[j][1])*
				(point[i][1]-point[j][1]);				
			}
			sort(length[i],length[i]+5);
		}
	/*	for(i=0;i<5;i++){
		   printf("%0.6lf\n",length[i][1]);
		}*/
		for(i=1;i<5;i++){
			//printf("%0.6lf\n",fabs(length[0][1]-length[i][1]));
			if(fabs(length[0][1]-length[i][1])>MIN)
			  ok=0;
		}
		if(ok)
		  printf("Yes\n");
		else
		 printf("No\n");
	}
	return 0;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值