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. 利用yield 实现Xrange功能

    def xrange(n): start = 0 while True: if start>n: return yield start start+=1 obj = xrange(5) n1 = ...

  2. day-7 一个简单的决策树归纳算法(ID3)python编程实现

    本文介绍如何利用决策树/判定树(decision tree)中决策树归纳算法(ID3)解决机器学习中的回归问题.文中介绍基于有监督的学习方式,如何利用年龄.收入.身份.收入.信用等级等特征值来判定用户 ...

  3. 【bug清除】新Surface Pro使用OneNote出现毛刺现象的解决方案

    在写字的时候,左手触摸Surface的金属外壳背面,大概两个手指指肚大小.问题亲测可以得到解决. 推测是设备使用时接地没有做好,导致电磁笔出现偏移.问题初步锁定在新笔的倾斜感应上. 参考资料: htt ...

  4. JavaSE阶段初期的一些问题

    ​​​对于如下问题1:编译阶段Demo1会报错,Demo2不会报错. class Demo1{ int i; i = 0; } class Demo2{ int i = 0; } 事实上,在java中 ...

  5. Nginx配置小结

    前两天区听了一堂Nginx的课,然后翻了一下自己之前的Nginx的笔记,做了一个简单的小结. 全局变量 $args : 这个变量等于请求行中的参数,同$query_string $content_le ...

  6. C语言使用vs2013进行编辑

    由于vs2013是微软开发的产品所以在windows平台下无限兼容windows所有虽然比较大,但是还是比较值得 但是在运行C程序的遇到问题就是控制台一闪而过通过ctrl+F5执行也是不管用: #in ...

  7. thinkphp调试技巧

    调试的经验:很多时候程序调试不出来,但是又找不出错误,往往是拼写错误可能是很小的拼写错误,很难看出,或者多了一个空格,比如在配置路由的时候'URL_ROUTER_ON '=true,这样设置就会错误, ...

  8. Echarts 折线图y轴标签值太长时显示不全的解决办法

    问题 分析 解决办法 问题 先看一下正常的情况 再看一下显示不全的情况 所有的数据都是从后台取的,也就是说动态变化的,一开始的时候数据量不大不会出现问题,后面y轴的值越来越大的时候就出现了这个显示不全 ...

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

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

  10. docker实践4

    我的docker学习笔记4-守护式容器   $docker run -i -t ubuntu /bin/bash $ctrl-p 或 ctrl-q # 转到后台   $docker ps $docke ...