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 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即

说明能够成正多边形

②要求输入的为整数,所以只有正四边形才能成立,判断下即可

#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
typedef long long ll;
double x[1005];
double y[1005];
double len[1005][1005]; double get_(int i,int j)
{
return sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
} int main()
{
int T,n;
scanf("%d",&T);
while(T--)
{
double tmin = 0x3f3f3f3f;
scanf("%d",&n);
for(int i = 1; i <= n; i++)
{
scanf("%lf%lf",&x[i],&y[i]);
}
for(int i = 1; i <= n; i++)
for(int j = i+1; j <= n; j++)
{
len[i][j] = get_(i,j);
tmin = min(tmin,len[i][j]);
}
int num = 0;
for(int i = 1; i <= n; i++)
for(int j = i+1; j <= n; j++)
{
if(tmin == len[i][j])
{
num++;
}
}
if(num == n)
printf("YES\n");
else
printf("NO\n");
}
return 0;
}

  

hdu 5533(几何水)的更多相关文章

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

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

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

  4. hdu 5210 delete 水题

    Delete Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5210 D ...

  5. HDU 2016 (水)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2016 题目大意:给你 n 个数,把最小的数和第一个数字互换,然后输出 解题思路: 很水,开数组,遍历并 ...

  6. HDU 2014 (水)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2014 题目大意:给你 n 个数,去掉 max 和 min ,求平均数 解题思路: 很水,边记录分数,边 ...

  7. HDU 2013 (水)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2013 题目大意:已知最后一天桃子只有一个,告诉你猴崽子第一天吃掉总桃子数的一半多一个,第二天吃掉剩下总 ...

  8. HDU 2011 (水)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2011 题目大意:给你 m 个数,对于每个数,求前 n 项和,数列:1 - 1/2 + 1/3 - 1/ ...

  9. HDU 2010 (水)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2010 题目大意:给你段连续的数,把满足条件(数字 每一位的3 == 该数字)的数输出,就是水仙花数 解 ...

随机推荐

  1. 201621123031 《Java程序设计》第2周学习总结

    Week02-Java基本语法与类库 1. 本周学习总结 本周讲了Java的基本数据类型,主要分为八类(byte,short,int,long,double,float,char,boolean),其 ...

  2. xapp1151_Param_CAM模块安装

    xapp1151_Param_CAM模块安装 所需生成模块 TCAM CAM 下载链接 赛灵思技术支持网站:http://www.xilinx.com/support.html 并在网页中搜索xapp ...

  3. 记一次jar包冲突

    题记:永远不要在同一个项目中,引用不同版本的两个jar包,否则,这可能就是一个大坑. 在做网校项目的时候,帮助中心要使用lucene,所以就引入了lucene-5.5.1的包,删掉了原先存在于项目中的 ...

  4. Java看书学习笔记

    1.POM:maven ,项目管理工具存放Jar包的文件2.mybatis-generator-core-1.3.2 生成文件 生成语句: java -jar mybatis-generator-co ...

  5. 剑指offer-删除链表中重复的节点

    题目描述   在一个排序的链表中,存在重复的结点,请删除该链表中重复的结点,重复的结点不保留,返回链表头指针. 例如,链表1->2->3->3->4->4->5 处 ...

  6. 解决IE下a标签点击有虚线边框的问题

    解决IE下a标签点击有虚线边框的问题 关键词:IE去除虚线边框.IE解决a标签虚线问题 先看看IE下,a标签出现的虚线边框问题: (上面中,红线包裹的就是一个翻页的按钮,按钮实际是hml的a标签做的, ...

  7. SpringBoot 概念和起步

    一.概念和由来 1.什么是 Spring Boot Spring Boot 的设计目的是用来简化新Spring应用的初始搭建以及开发过程.该框架使用特定方式来进行配置,从而使开发人员不再需要定义样板化 ...

  8. testNG常用方法

    1.常用注释: 注解                  描述 @BeforeSuite                       在该套件的所有测试都运行在注释的方法之前,仅运行一次. @After ...

  9. Spark:性能调优

    来自:http://blog.csdn.net/u012102306/article/details/51637366 资源参数调优 了解完了Spark作业运行的基本原理之后,对资源相关的参数就容易理 ...

  10. hdu1060 Leftmost Digit---求N的N次方的首位(对数)

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1060 题目描述:求N的N次方的第一位. 思路: 第一次做这种类型的题目,学到了如何运用对数. 首先推 ...