Dancing Stars on Me

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)
Total Submission(s): 2460    Accepted Submission(s): 1420

Problem Description
The sky was brushed clean by the wind and the stars were cold in a black sky. What a wonderful night. You observed that, sometimes the stars can form a regular polygon in the sky if we connect them properly. You want to record these moments by your smart camera. Of course, you cannot stay awake all night for capturing. So you decide to write a program running on the smart camera to check whether the stars can form a regular polygon and capture these moments automatically.

Formally, a regular polygon is a convex polygon whose angles are all equal and all its sides have the same length. The area of a regular polygon must be nonzero. We say the stars can form a regular polygon if they are exactly the vertices of some regular polygon. To simplify the problem, we project the sky to a two-dimensional plane here, and you just need to check whether the stars can form a regular polygon in this plane.

 
Input
The first line contains a integer T indicating the total number of test cases. Each test case begins with an integer n, denoting the number of stars in the sky. Following nlines, each contains 2 integers xi,yi, describe the coordinates of n stars.

1≤T≤300
3≤n≤100
−10000≤xi,yi≤10000
All coordinates are distinct.

 
Output
For each test case, please output "`YES`" if the stars can form a regular polygon. Otherwise, output "`NO`" (both without quotes).
 
Sample Input
3
3
0 0
1 1
1 0
4
0 0
0 1
1 0
1 1
5
0 0
0 1
0 2
2 2
2 0
 
Sample Output
NO
YES
NO
 
Source
 
Recommend
 
 
 #define  N  109
int t,n;
double x[N],y[N];
double x_,y_;
double dis(double x,double y){
return sqrt((x-x_)*(x-x_)+(y-y_)*(y-y_));
}
int main()
{
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
x_=,y_=;
for(int i=;i<n;i++){
scanf("%lf%lf",&x[i],&y[i]);
x_+=x[i]/n;
y_+=y[i]/n;
}
double temp=dis(x[],y[]);
int flag=;
for(int i=;i<n;i++)
{
if(dis(x[i],y[i])!=temp){
flag=;
break;
}
}
if(flag){
printf("YES\n");
}
else{
printf("NO\n");
}
}
return ;
} //结论 在平面内,如果坐标都为整数,那么只有可能是正四边形
//1 1 1 1 2 2(排序后边长比例)
int x[N],y[N];
int a[];
bool check()
{
if(n!=) return false;
int cnt=;
for(int i=;i<;i++)
{
for(int j=i+;j<;j++)
{
a[cnt++]=(x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]);
}
}
sort(a,a+cnt);
if(a[]==a[]&&a[]==a[]&&a[]==a[]&&a[]==*a[]&&a[]==a[])
return true;
return false;
}
int main()
{
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
for(int i=;i<n;i++){
scanf("%d%d",&x[i],&y[i]);
}
if(check()){
printf("YES\n");
}
else{
printf("NO\n");
}
}
return ;
}

hdu 5533的更多相关文章

  1. hdu 5533 Dancing Stars on Me 水题

    Dancing Stars on Me Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.p ...

  2. hdu 5533 Dancing Stars on Me

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5533 Dancing Stars on Me Time Limit: 2000/1000 MS (Ja ...

  3. 2015ACM/ICPC亚洲区长春站 G hdu 5533 Dancing Stars on Me

    Dancing Stars on Me Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Ot ...

  4. 2015ACM/ICPC亚洲区长春站 F hdu 5533 Almost Sorted Array

    Almost Sorted Array Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Ot ...

  5. hdu 5533 Dancing Stars on Me(数学,水)

    Problem Description The sky was brushed clean by the wind and the stars were cold in a black sky. Wh ...

  6. hdu 5533(几何水)

    Input The first line contains a integer T indicating the total number of test cases. Each test case ...

  7. HDU 5533/ 2015长春区域 G.Dancing Stars on Me 暴力

    Dancing Stars on Me Problem Description The sky was brushed clean by the wind and the stars were col ...

  8. HDU 5533 Dancing Stars on Me( 有趣的计算几何 )

    链接:传送门 题意:给出 n 个点,判断能不能构成一个正 n 边形,这 n 个点坐标是整数 思路:这道题关键就在与这 n 个点坐标是正整数!!!可以简单的分析,如果 n != 4,那一定就不能构成正 ...

  9. hdu 5533 正n边形判断 精度处理

    Dancing Stars on Me Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Ot ...

随机推荐

  1. Vnc在Ubuntu14.04上的安装和配置 安装:

    安装: Ubuntu14.04 : sudo apt-get install vnc4server : sudo apt-get install xrdp iPad : 安装 vnc viewer 或 ...

  2. HDU 2243 考研路茫茫——单词情结 求长度小于等于L的通路总数的方法

    http://acm.hdu.edu.cn/showproblem.php?pid=2243 这是一题AC自动机 + 矩阵快速幂的题目, 首先知道总答案应该是26^1 + 26^2 + 26^3 .. ...

  3. Windows7&IIS7.5部署Discuz全攻略

    组长说在内网部署一个论坛,这可难不倒我,装个Discuz嘛.部署环境就一台普通的PC,四核i3,Windows7.这就开搞了. 准备工作 系统是Windows 7 专业版,自带IIS7.5(家庭版不带 ...

  4. .NET资源站点汇总~

    名称:快速入门地址:http://chs.gotdotnet.com/quickstart/描述:本站点是微软.NET技术的快速入门网站,我们不必再安装.NET Framework中的快速入门示例程序 ...

  5. html学习笔记-XML-Javascript

    html学习笔记-XML-Javascript Table of Contents 1. XML HTTP Request 1.1. XMLHttpRequest 对象 1.2. 创建 XMLHttp ...

  6. jQuery toggle 使用

    jQuery 中 toggle 作用 切换元素的显示与隐藏状态 如果被选元素可见,则隐藏这些元素,如果被选元素隐藏,则显示这些元素. <body> <div class=" ...

  7. python之map,zip,reduce,filter的用法

    1.reduce(func,iterable,initial): 参数: - func 可执行函数 - iterable 可迭代对象 - initial 可选,初始参数 功能描述:调用func函数后, ...

  8. git的常用操作指令

    git学习网址: http://www.backlogtool.com/git-guide/cn/intro/intro2_3.html 廖雪峰的git教程 git的工作区和暂存区(描述git的工作流 ...

  9. 火狐浏览器不支持location.reload()(以改变页面大小时重新刷新页面为例)

    背景:当页面大小改变时需要重新刷新页面,以适应相应的尺寸 解决方法: var url = window.location.href; var parm = parseInt(Math.random() ...

  10. 最新电脑公司最新GHOST WIN7系统32,64位极速安全版

    系统来自系统妈:http://www.xitongma.com 电脑公司最新GHOST win7系统64位极速安全版 V2016年3月 系统简介 电脑公司ghost win7系统64位极速安全版集成了 ...