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. Digilent Xilinx USB Jtag cable

    Digilent Xilinx USB Jtag cable 安装环境 操作系统:fedora 20 64bit 源链接:https://wiki.gentoo.org/wiki/Xilinx_USB ...

  2. bzoj千题计划276:bzoj4515: [Sdoi2016]游戏

    http://www.lydsy.com/JudgeOnline/problem.php?id=4515 把lca带进式子,得到新的式子 然后就是 维护树上一次函数取min 一个调了一下午的错误: 当 ...

  3. 从PRISM开始学WPF(二)Prism?

    目录: 从PRISM开始学WPF(一)WPF? 从PRISM开始学WPF(二)Prism? 从PRISM开始学WPF(三)Prism-Region? 从PRISM开始学WPF(四)Prism-Modu ...

  4. Solr搜索引擎搭建详细过程

    1    什么是solr Solr 是Apache下的一个顶级开源项目,采用Java开发,它是基于Lucene的全文搜索服务器.Solr可以独立运行在Jetty.Tomcat等这些Servlet容器中 ...

  5. css3动画transition详解

    一.transition-property 语法: transition-property : none | all | [ <IDENT> ] [ ',' <IDENT> ] ...

  6. Entity Framework Core Code First

    参考地址:https://docs.microsoft.com/zh-cn/ef/core/get-started/aspnetcore/new-db

  7. JAVA_SE基础——62.String类的构造方法

    下面我先列出初学者目前用到的构造方法 String 的构造方法:     String()  创建一个空内容 的字符串对象.   String(byte[] bytes)  使用一个字节数组构建一个字 ...

  8. ios开发常识(1)开发语言和参考资料

    学iphone开发用的语言是object-c,object-c和c++,java还是有很大区别,如果你坚持学习iphone开发的话可以不学c++,java,直接学习这个语言,先入为主,可能觉得这个语言 ...

  9. 阿里云API网关(5)用户指南(调用 API)

    网关指南: https://help.aliyun.com/document_detail/29487.html?spm=5176.doc48835.6.550.23Oqbl 网关控制台: https ...

  10. OAuth2.0学习(1-8) 授权方式五之Access_Token令牌过期更新

    OAuth2.0的Access_Token令牌过期更新 如果用户访问的时候,客户端的"访问令牌"已经过期,则需要使用"更新令牌"申请一个新的访问令牌. 客户端发 ...