hdu 5533
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
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.
1≤T≤300
3≤n≤100
−10000≤xi,yi≤10000
All coordinates are distinct.
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
YES
NO
#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的更多相关文章
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- hdu 5533(几何水)
Input The first line contains a integer T indicating the total number of test cases. Each test case ...
- 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 ...
- HDU 5533 Dancing Stars on Me( 有趣的计算几何 )
链接:传送门 题意:给出 n 个点,判断能不能构成一个正 n 边形,这 n 个点坐标是整数 思路:这道题关键就在与这 n 个点坐标是正整数!!!可以简单的分析,如果 n != 4,那一定就不能构成正 ...
- hdu 5533 正n边形判断 精度处理
Dancing Stars on Me Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Ot ...
随机推荐
- H5gulp版非前后的分离环境
由于公司不同意我们使用前后端分离进行开发,硬是要我们和PHP混合在一起,所以用gulp搭建了一个简单的手脚架来用 目录结构: 主要是gulpfile.js里的内容 var gulp = require ...
- 第十六章 提升用户体验 之 设计实现routes
1. 概述 ASP.NET MVC route 用来把URL映射到方法中的action,是用户和程序之间的桥梁. 本章内容包括:定义route处理URL Pattern.应用route限制.忽略URL ...
- JAVA常量介绍
常量: 在程序执行过程中,其值不发生改变的量: 1.分类: 字面值常量和自定义常量: 1.字面值常量有以下几种: 字符串常量.小数常量.整数常量.字符常量.布尔常量(true.false).空 ...
- TCP的三次握手以及TCP状态转换图详解
今天来讨论一下TCP的三次握手以及TCP的状态转换图.首先发一个三次握手的流程图如下: 圖 2.4-3.三向交握之封包连接模式A:封包发起当用戶端想要对服务器端发起连接时,就必須要送出一個要求连线的封 ...
- Windows7(x86) xampp php5.5 imagick install
I hate windows. 1. 下载安装 ImageMagick, 选择合适您电脑的版本,我下载的是: ImageMagick-6.8.9-1-Q16-x86-dll.exe http://ww ...
- UVA11019 Matrix Matcher (AC自动机)
二维的矩阵匹配,把模式矩阵按列拆开构造AC自动机,记录行号(为了缩点判断). 把T矩阵按行匹配,一旦匹配成功,在假想的子矩阵左上角位置加一.最后统计总数. 因为所有模式串长度一样,不用维护last数组 ...
- codeforce Gym 100570B ShortestPath Query (最短路SPFA)
题意:询问单源最短路径,每条边有一个颜色,要求路径上相邻边的颜色不能相同,无重边且边权为正. 题解:因为路径的合法性和边的颜色有关, 所以在做spfa的时候,把边丢到队列中去,松弛的时候注意判断一下颜 ...
- Android(java)学习笔记137:ListView编写步骤(重点)
1.ListView在我们的手机android编写程序中使用是十分广泛的,比如如下图中 短信 和 手机设置 都是ListView的效果: 手机设置: 短信: 2.正因为这 ...
- C++ 值传递&引用&地址
- Dojo常用函数
1.array函数:和原生的JavaScript中的数组遍历方法forEach方法用法相同 define(['dojo/_base/declare', "dojo/_base/array&q ...