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

题意:

给出n个点,判断这n个点能否组成正n边形。

思路:

由于n的范围较小,所以可以直接暴力求解。因为正n边形上各点到其他点的最短距离即是该正n边形的边长w,所以只要判断下所有点之间的最短距离是否均为w即可!

题目链接

#include<bits/stdc++.h>
#define MAX 100
#define INF 0x3f3f3f3f
using namespace std;
int x[MAX+],y[MAX+],e[MAX+][MAX+];
int dis(int a,int b)
{
return ((x[a]-x[b])*(x[a]-x[b])+(y[a]-y[b])*(y[a]-y[b]));
}
int main()
{
int T;
scanf("%d",&T);
while(T--)
{
memset(e,INF,sizeof(e));
int n,i,j,sum=;
scanf("%d",&n);
for(i=;i<=n;i++)
scanf("%d%d",&x[i],&y[i]);
int minn=INF;
for(i=;i<=n;i++)
{
for(j=i+;j<=n;j++)
{
e[i][j]=dis(i,j);
minn=min(minn,e[i][j]);
}
}
for(i=;i<=n;i++)
for(j=i+;j<=n;j++)
if(minn==e[i][j])
sum++;
if(sum==n) printf("YES\n");
else printf("NO\n");
}
return ;
}

【2015 ICPC亚洲区域赛长春站 G】Dancing Stars on Me(几何+暴力)的更多相关文章

  1. 2015 ACM / ICPC 亚洲区域赛总结(长春站&北京站)

    队名:Unlimited Code Works(无尽编码)  队员:Wu.Wang.Zhou 先说一下队伍:Wu是大三学长:Wang高中noip省一:我最渣,去年来大学开始学的a+b,参加今年区域赛之 ...

  2. 2014ACM/ICPC亚洲区域赛牡丹江站汇总

    球队内线我也总水平,这所学校得到了前所未有的8地方,因为只有两个少年队.因此,我们13并且可以被分配到的地方,因为13和非常大的数目.据领队谁oj在之上a谁去让更多的冠军.我和tyh,sxk,doub ...

  3. 【2013 ICPC亚洲区域赛成都站 F】Fibonacci Tree(最小生成树+思维)

    Problem Description Coach Pang is interested in Fibonacci numbers while Uncle Yang wants him to do s ...

  4. 【2018 ICPC亚洲区域赛徐州站 A】Rikka with Minimum Spanning Trees(求最小生成树个数与总权值的乘积)

    Hello everyone! I am your old friend Rikka. Welcome to Xuzhou. This is the first problem, which is a ...

  5. 2014ACM/ICPC亚洲区域赛牡丹江现场赛总结

    不知道怎样说起-- 感觉还没那个比赛的感觉呢?如今就结束了. 9号.10号的时候学校还评比国奖.励志奖啥的,由于要来比赛,所以那些事情队友的国奖不能答辩.自己的励志奖班里乱搞要投票,自己又不在,真是无 ...

  6. 2014ACM/ICPC亚洲区域赛牡丹江站现场赛-K ( ZOJ 3829 ) Known Notation

    Known Notation Time Limit: 2 Seconds      Memory Limit: 65536 KB Do you know reverse Polish notation ...

  7. 【2017 ICPC亚洲区域赛北京站 J】Pangu and Stones(区间dp)

    In Chinese mythology, Pangu is the first living being and the creator of the sky and the earth. He w ...

  8. 【2016 ICPC亚洲区域赛北京站 E】What a Ridiculous Election(BFS预处理)

    Description In country Light Tower, a presidential election is going on. There are two candidates,   ...

  9. 【2018 ICPC亚洲区域赛南京站 A】Adrien and Austin(博弈)

    题意: 有一排n个石子(注意n可以为0),每次可以取1~K个连续的石子,Adrien先手,Austin后手,若谁不能取则谁输. 思路: (1) n为0时的情况进行特判,后手必胜. (2) 当k=1时, ...

随机推荐

  1. jQuery阻止向上冒泡事件

    //阻止起泡取消下面的注释 e.stopPropagation(); //或者使用这种方式 //return false; }); $('.three').click(function(e){ ale ...

  2. Easyui datagrid加载数据时默认全选的问题

    问题描述: 最近使用 Easyui datagrid 展示数据,之前一直使用很正常,今天出现了一个怪异问题 加载数据后,只要点击选中列 ck 的任意行或多行,再刷新时整个datagrid的所有数据都 ...

  3. 【阿里云产品公测】ACE下上传文件永久存储实践

    本帖主要内容: ;$,=VB:'   在阿里云的ACE下,我是如何实现让上传的文件永久保存的? ,%"!8T   本文以PHP为例,具体知识点如下: WD# 96V   第一,扩展服务“存储 ...

  4. 安卓基础干货(六):安卓Activity的学习

    AndroidManifest文件中的几个细节 结论: 1.一个应用程序可以创建多个桌面图标 2.创建快捷图标的方法: <intent-filter> //应用程序的入口 <acti ...

  5. python SQLAchemy常用语法

    SQLAlchemy是Python编程语言下的一款ORM框架,该框架建立在数据库API之上,使用关系对象映射进行数据库操作,简言之便是:将对象转换成SQL,然后使用数据API执行SQL并获取执行结果. ...

  6. DBGridEh常用技巧

    一.增加多表头显示方式 DBGridEh1.UseMultiTitle:=True; //打开多标题显示方式 DBGridEh1.Columns[].Title.Caption:='员工编号'; // ...

  7. Linux 虚拟机中配置 GNOME + VNC

    需求描述 在特定的需求下,需要用到 Linux 的图形化界面,但是 Azure 平台提供的虚拟机默认没有开放远程图形化登陆的功能.以下解决方案,提供了市面上非常流行的 GNOME + VNC 的组合来 ...

  8. easyui的解析器Parser

    平时使用easyui做框架开发时,都知道easyui的模块组件能通过属性方法或js方法来渲染,本质上是通过parser解析器来处理实现的,因为多数情况下都是自动触发完成整个页面的解析,所以没有感觉到它 ...

  9. 华为HCNP实验 防火墙安全区域及安全策略配置(USG6000)

    防火墙安全区域及安全策略配置   一.学习目的 掌握防火墙安全区域的配置方法 掌握安全策略的配置方法   二.拓扑图         三.场景 你是公司的网络管理员.公司总部的网络分成了三个区域,包括 ...

  10. February 2 2017 Week 5 Thursday

    Only do what your heart tells you. 随心而行. My heart tells me that I should leave here and go back to X ...