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. dtexec命令执行SSIS包

    默认情况下,同时安装了 64 位和 32 位版本的 Integration Services 命令提示实用工具的 64 位计算机将在命令提示符处运行 32 位版本.运行 32 位版本的原因是:在 PA ...

  2. 物体检测丨从R-CNN到Mask R-CNN

    这篇blog是我刚入目标检测方向,导师发给我的文献导读,深入浅出总结了object detection two-stage流派Faster R-CNN的发展史,读起来非常有趣.我一直想翻译这篇博客,在 ...

  3. css常用操作

    对齐操作 1.使用margin属性进行水平对齐     margin-left:auto;    margin-right:auto; 2.使用position属性进行左右对齐      3.使用fl ...

  4. Android 4.4及以后将内容布局延伸到状态栏

    首先说明:该文章不是大家说的沉浸式状态栏,网上沉浸式状态栏的博客很多,搜索就有了! 该篇博客的主要目的就是为了将图片显示在状态栏上,让APP看起来更有型!如下图所示:   界面 这个界面的布局就是co ...

  5. windows系统下Eclipse启动界面更改

    前段日子看到有人修改了linux系统下Eclipse的启动界面,因此自己试着修改了一下windows平台的启动界面.本文总结一下修改Eclipse 4.5(代号Mars)启动界面的方法. 方法一:修改 ...

  6. JavaScript命名——name不能做变量名

    使用name作为变量名(var name = ‘’),在IE中未引起bug,在Chrome中引起bug但未明确指出命名错误,而是会报其他错误,故不便于发现. 现象原因: javascript中name ...

  7. Countup.js:vue-countup-v2(npm)数字滚动插件

    1.官方地址:http://inorganik.github.io/countUp.js/ 2.官方demo: 3.参数说明: params——start(开始数字).end(结束数字).decima ...

  8. UOJ#7 NOI2014 购票 点分治+凸包二分 斜率优化DP

    [NOI2014]购票 链接:http://uoj.ac/problem/7 因为太麻烦了,而且暴露了我很多学习不扎实的问题,所以记录一下具体做法. 主要算法:点分治+凸包优化斜率DP. 因为$q_i ...

  9. SAP成都研究院DevOps那些事

    今天的文章来自我的同事平静静,SAP成都研究院一位程序媛.平静静2010年加入SAP,熟悉她的人一般都叫她平静.在她待过的每个小组,平静静都不是最引人瞩目的开发人员,然而她总是能一如既往,保质保量地完 ...

  10. 关于tomcat的classloader的一点想法

    关于tomcat的classloader相关的帖子网上非常多,我觉得比较好的有: https://www.jianshu.com/p/d90e4430b0b9 https://blog.csdn.ne ...