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 n lines, each contains  integers xi,yi, describe the coordinates of n stars.

≤T≤
≤n≤
−≤xi,yi≤
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

 
Sample Output
NO
YES
NO
 
Source
 
题意:给你几个点,判断这几个点能否组成正n边形
先算出两两之间的距离存于mp[][]数组,然后找出最小的距离minnn,如果mp数组刚好有n个等于minnn,则是正多边形
 #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(数学,水)的更多相关文章

  1. 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 ...

  2. 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 ...

  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. HDU 5533 Dancing Stars on Me( 有趣的计算几何 )

    链接:传送门 题意:给出 n 个点,判断能不能构成一个正 n 边形,这 n 个点坐标是整数 思路:这道题关键就在与这 n 个点坐标是正整数!!!可以简单的分析,如果 n != 4,那一定就不能构成正 ...

  5. 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 ...

  6. HDU 5832 A water problem(某水题)

    p.MsoNormal { margin: 0pt; margin-bottom: .0001pt; text-align: justify; font-family: Calibri; font-s ...

  7. Dancing Stars on Me(判断正多边形)

    Dancing Stars on Me Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Ot ...

  8. [hdu 6184 Counting Stars(三元环计数)

    hdu 6184 Counting Stars(三元环计数) 题意: 给一张n个点m条边的无向图,问有多少个\(A-structure\) 其中\(A-structure\)满足\(V=(A,B,C, ...

  9. hdu 5533

    Dancing Stars on Me Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Ot ...

随机推荐

  1. Binary Tree Level Order Traversal 解答

    Question Given a binary tree, return the level order traversal of its nodes' values. (ie, from left ...

  2. Intersection of Two Linked Lists 解答

    Question Write a program to find the node at which the intersection of two singly linked lists begin ...

  3. VC++6.0出现no compile tool is associated with the extension.解决方法

    对于刚解除VC++6.0的小白,在编译时候经常出现下图的错误提示: 解释为:不能编译此BmpRot.h文件,没有合适的编译工具可以编译此扩展名的文件. 很明显,当然只有.cpp文件才能编译. .h头文 ...

  4. 【LeetCode练习题】Minimum Depth of Binary Tree

    Minimum Depth of Binary Tree Given a binary tree, find its minimum depth. The minimum depth is the n ...

  5. Java安装根目录

    bin存放了Java的操作工具,比如编译工具javac.启动JVM的Java等 db存放了Java测试的数据库Derby,企业不用 include存放C++的头文件 jre运行环境,里面有JVM li ...

  6. 怎么用MindMapper分类功能整理导图

    我们在绘制导图时是按着我们大脑中的思维来的,虽然有着总体逻辑,但是在细节上面还是不可避免的有些小杂乱,我们则可以通过MindMapper分类功能来对导图进行整理. 我们在打开MindMapper思维导 ...

  7. jsp用jstl标签比较枚举

    日向博客最近在优化,有这一样一个小问题,我希望在下面的消息中心页面,未读的消息链接显示蓝色,已读的消息显示红色: 这就需要用jstl做一个判断. 之前的代码是这种形式: 消息中心:<br> ...

  8. C#.Net前台线程与后台线程的区别

    本文来自:http://www.cnblogs.com/zfanlong1314/archive/2012/02/26/2390455.html .Net的公用语言运行时(Common Languag ...

  9. Java 线程第三版 第八章 Thread与Collection Class 读书笔记

        JDK1.2引入最有争议性的改变是将集合类默觉得不是Thread安全性的. 一.Collection Class的概述 1. 具有Threadsafe 的Collection Class: j ...

  10. libaio under MIPS architecture /在mips架构下使用的libaio

    First, you can find libaio source in http://libaio.sourcearchive.com/ Second,download the libaio_0.3 ...