HDU 5533/ 2015长春区域 G.Dancing Stars on Me 暴力
Dancing Stars on Me
Problem Description
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.
indicating the total number of test cases. Each test case begins with an integer n
, denoting the number of stars in the sky. Following n
lines, each contains 2
integers xi
,y
i
, describe the coordinates of n
stars.
1≤T≤300
3≤n≤100
−10000≤xi
,y
i
≤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
///
#include<bits/stdc++.h>
using namespace std ;
typedef long long ll;
#define mem(a) memset(a,0,sizeof(a))
#define meminf(a) memset(a,127,sizeof(a)); inline ll read()
{
ll x=,f=;char ch=getchar();
while(ch<''||ch>''){
if(ch=='-')f=-;ch=getchar();
}
while(ch>=''&&ch<=''){
x=x*+ch-'';ch=getchar();
}return x*f;
}
//**************************************** const int inf=;
#define maxn 150
struct node
{
int x;
int y;
}p[maxn];
int d[];
int n,x[maxn],y[maxn];
int dis(node a,node b)
{
return (a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y);
}
bool test()
{
int ans=inf;
d[]=dis(p[],p[]);
d[]=dis(p[],p[]);
d[]=dis(p[],p[]);
d[]=dis(p[],p[]);
d[]=dis(p[],p[]);
d[]=dis(p[],p[]);
sort(d,d+);
if(d[]==d[]&&d[]==d[]&&d[]==d[]&&*d[]==d[]&&d[]==d[])
{
return ;
}
return ;
}
int main(){
int T=read();
while(T--){
scanf("%d",&n);
for(int i=;i<n;i++){
scanf("%d%d",&x[i],&y[i]);
}
if(n!=){
cout<<"NO"<<endl;
}
else {
for(int i=;i<;i++){
node aa;
aa.x=x[i],aa.y=y[i];
p[i]=aa;
}
if(test())cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
}
return ;
}
代码
HDU 5533/ 2015长春区域 G.Dancing Stars on Me 暴力的更多相关文章
- HDU 5536/ 2015长春区域 J.Chip Factory Trie
Chip Factory Problem Description John is a manager of a CPU chip factory, the factory produces lots ...
- HDU 5534/ 2015长春区域H.Partial Tree DP
Partial Tree Problem Description In mathematics, and more specifically in graph theory, a tree is an ...
- Travel(HDU 5441 2015长春区域赛 带权并查集)
Travel Time Limit: 1500/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Su ...
- HDU 5538/ 2015长春区域 L.House Building 水题
题意:求给出图的表面积,不包括底面 #include<bits/stdc++.h> using namespace std ; typedef long long ll; #define ...
- hdu 5443 (2015长春网赛G题 求区间最值)
求区间最值,数据范围也很小,因为只会线段树,所以套了线段树模板=.= Sample Input3110011 151 2 3 4 551 21 32 43 43 531 999999 141 11 2 ...
- hdu 5446(2015长春网络赛J题 Lucas定理+中国剩余定理)
题意:M=p1*p2*...pk:求C(n,m)%M,pi小于10^5,n,m,M都是小于10^18. pi为质数 M不一定是质数 所以只能用Lucas定理求k次 C(n,m)%Pi最后会得到一个同余 ...
- 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 ...
- 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 ...
随机推荐
- Java常用类库(二):Iterator迭代器和子范围视图
今天介绍集合类的以下内容: l Iterator迭代器 l 子范围视图简介 Iterator迭代器: 应该将java迭代器认为是位于两个元素之间, 当调用next 时,迭代器就越过下一个元素,并返 ...
- Android RecyclerView利用Glide加载大量图片into(Target)导致OOM异常
学过android的人应该都知道Glide是一个无比强大的图片加载库,它内部已经提供了很好的缓存机制供我们选择,我们只需一个参数调用即可(DiskCacheStrategy()),而不必像Univer ...
- 高级Java知识
高级Java知识(JVM.字节码.内存模型) 内存=方法区+栈空间+堆+程序计数器 栈(stack)包括虚拟机栈(VM stack)和本地方法栈(native method stack). 方法区(m ...
- JS——冒泡案例
模态框 1.因为a链接和和顶级document都注册了单击事件,所以要阻止a链接向父级盒子冒泡,不然又会从document的单击事件走一遍 2.在document的单击事件中,只需要判断触发事件的目标 ...
- (转)Arcgis for JS之Cluster聚类分析的实现
http://blog.csdn.net/gisshixisheng/article/details/40711075 在做项目的时候,碰见了这样一个问题:给地图上标注点对象,数据是从数据库来的,包含 ...
- 吐得了,vue的多选组合框回显必须是字符串集合
下面这个typeIdList,如果给他赋值,就能回显到页面,但是必须是字符串的集合,如果是数值类型的id,不好意思,请转成字符串
- Django中 基于form的注册,基于ajax的登录
1 form.py中写register的的form组件 from django import forms class Register(forms.Form): # 注册的form username ...
- WPF在win7运行时报'Initialization of 'System.Windows.Setter' threw an exception.'
写的一个WPF程序,在win10运行好好的,在win7就报'Initialization of 'System.Windows.Setter' threw an exception.' 原来是xaml ...
- 使用form标签时注意事项
今天写程序的时候,使用了一个form:select标签,然后系统一直报错 原因找了好久也没找到 后来咨询得知, 在使用form:标签的时候 前后的form标签要写成<form:form> ...
- 计蒜客 劫富济贫 (Trie树)
链接 : Here! 思路 : Trie树裸题, 由开始给出的名字建一棵字典树, 然后每次查询一下抢♂劫的人名是否在字典树中, 复杂度也不清楚是多少, 反正是没给出 $M$ 的范围, 开始时用 $ha ...