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. 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.
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 n lines, each contains integers xi,yi, describe the coordinates of n stars. ≤T≤
≤n≤
−≤xi,yi≤
All coordinates are distinct.
For each test case, please output "`YES`" if the stars can form a regular polygon. Otherwise, output "`NO`" (both without quotes).
NO
YES
NO
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<math.h>
#include<algorithm>
#include<queue>
#include<set>
#include<bitset>
#include<map>
#include<vector>
#include<stdlib.h>
#include <stack>
using namespace std;
#define PI acos(-1.0)
#define max(a,b) (a) > (b) ? (a) : (b)
#define min(a,b) (a) < (b) ? (a) : (b)
#define ll long long
#define eps 1e-10
#define MOD 1000000007
#define N 106
#define inf 1<<26
int n;
double x[N],y[N];
double mp[N][N];
double cal(int i,int j){
return ((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
}
int main()
{
int t;
scanf("%d",&t);
while(t--){
scanf("%d",&n);
for(int i=;i<n;i++){
scanf("%lf%lf",&x[i],&y[i]);
}
double minnn=inf;
for(int i=;i<n;i++){
for(int j=i+;j<n;j++){
mp[i][j]=cal(i,j);
if(minnn>mp[i][j]){
minnn=mp[i][j];
}
}
}
int ans=;
for(int i=;i<n;i++){
for(int j=i+;j<n;j++){
if(mp[i][j]==minnn){
ans++;
}
}
}
if(ans==n){
printf("YES\n");
}else{
printf("NO\n");
}
}
return ;
}
hdu 5533 Dancing Stars on Me(数学,水)的更多相关文章
- 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 ...
- 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 ...
- 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( 有趣的计算几何 )
链接:传送门 题意:给出 n 个点,判断能不能构成一个正 n 边形,这 n 个点坐标是整数 思路:这道题关键就在与这 n 个点坐标是正整数!!!可以简单的分析,如果 n != 4,那一定就不能构成正 ...
- 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 5832 A water problem(某水题)
p.MsoNormal { margin: 0pt; margin-bottom: .0001pt; text-align: justify; font-family: Calibri; font-s ...
- Dancing Stars on Me(判断正多边形)
Dancing Stars on Me Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Ot ...
- [hdu 6184 Counting Stars(三元环计数)
hdu 6184 Counting Stars(三元环计数) 题意: 给一张n个点m条边的无向图,问有多少个\(A-structure\) 其中\(A-structure\)满足\(V=(A,B,C, ...
- hdu 5533
Dancing Stars on Me Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Ot ...
随机推荐
- 匿名函数中undefined形参疑问(转载)
唉,基本功不扎实,昨天在微博上问了个问题,就匿名函数中undefined形参,不知道是干什么用的. 经常看到这样的匿名函数代码: ;(function( $, window, document,und ...
- 《MATLAB数据分析与挖掘实战》赠书活动
<MATLAB数据分析与挖掘实战>是泰迪科技在数据挖掘领域探索10余年经验总结与华南师大.韩山师院.广东工大.广技师 等高校资深讲师联合倾力打造的巅峰之作.全书以实践和实用为宗旨,深度 ...
- 手动调整导航控制器中的viewcontroller
NSMutableArray *array = [[NSMutableArray alloc]initWithArray: [self.navigationController viewControl ...
- HBase的基本操作
1.输入hbase shell进入HBase shell
- 字符串和数字的全排列问题、前i位被i整除问题
// 全排列问题.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" #include <iostream> using names ...
- 使用秘钥对登录Linux系统
一,用密码登录系统,可能由于密码的简单或者其他原因造成被其他人登录,这样服务器可是很不安全的,为此我们可以使用秘钥登录系统. 二, 1,设置密钥对前,我们需要下载一个工具 https://the.ea ...
- Tomcat 的三种(bio,nio.apr) 高级 Connector 运行模式
tomcat的运行模式有3种.修改他们的运行模式.3种模式的运行是否成功,可以看他的启动控制台,或者启动日志.或者登录他们的默认页面http://localhost:8080/查看其中的服务器状态. ...
- 数据库学习之ADO.NET五大对象
1 [ADO.NET] ado.net 是一种数据访问技术,使得应用程序能够连接到数据存储,并以各种方式操作存储在里面的数据. 2 [ADO.NET五大常用对象] Connec ...
- 高效的SQL分页存储过程
CREATE PROCEDURE SP_CommonPageList @Fields VARCHAR(500), @From VARCHAR(1000), @Condition VARCHAR(100 ...
- MySQL安装配置过程
1.下载压缩包,解压: 2: 修改 my-default.ini 文件 将一下代码前# 去掉修改成自己的地址 # These are commonly set, remove the # and s ...