hdu 5533(几何水)
1≤T≤300
3≤n≤100
−10000≤xi,yi≤10000
All coordinates are distinct.
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
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(几何水)的更多相关文章
- 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 ...
- 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 ...
- 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 5210 delete 水题
Delete Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5210 D ...
- HDU 2016 (水)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2016 题目大意:给你 n 个数,把最小的数和第一个数字互换,然后输出 解题思路: 很水,开数组,遍历并 ...
- HDU 2014 (水)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2014 题目大意:给你 n 个数,去掉 max 和 min ,求平均数 解题思路: 很水,边记录分数,边 ...
- HDU 2013 (水)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2013 题目大意:已知最后一天桃子只有一个,告诉你猴崽子第一天吃掉总桃子数的一半多一个,第二天吃掉剩下总 ...
- HDU 2011 (水)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2011 题目大意:给你 m 个数,对于每个数,求前 n 项和,数列:1 - 1/2 + 1/3 - 1/ ...
- HDU 2010 (水)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2010 题目大意:给你段连续的数,把满足条件(数字 每一位的3 == 该数字)的数输出,就是水仙花数 解 ...
随机推荐
- iOS极光推送SDK的使用流程
一.极光推送简介 极光推送是一个端到端的推送服务,使得服务器端消息能够及时地推送到终端用户手机上,整合了iOS.Android和WP平台的统一推送服务.使用起来方便简单,已于集成,解决了原生远程推送繁 ...
- tornado web高级开发项目
抽屉官网:http://dig.chouti.com/ 一.配置(settings) settings = { 'template_path': 'views', #模板文件路径 'static_pa ...
- 08-TypeScript中的类
类的概念通常是在后端开发中实现的思想,比如C#.C++或Java,传统的JavaScript开发通过使用原型模式来模拟类的功能.在TypeScript中,天生就是支持类 的,可以让前端的开发更加具有面 ...
- iot前台开发环境:搭建 SpringBoot+angularJs2
参考网站 Angular 中文官网:https://angular.cn/ 参考代码:https://ng.ant.design/#/components/dropdown npm install ...
- hadoop2.6.0实践:002 检查伪分布式环境搭建
1.检查网络配置[root@hadoop-master ~]# cat /etc/sysconfig/networkNETWORKING=yesHOSTNAME=hadoop-masterGATEWA ...
- iOS 封装.framework 以及使用
.framework是什么? .framework是什么? 这个问题相信做iOS的都知道答案. 在我们的日常开发中,经常会用到各种已经封装好的库,比如支付宝.微信SDK等等中的库,这些库可以给我们的开 ...
- Python学习之list有序集合
# coding=utf-8 # list有序集合 classmate = ['Michael', 'Bob', 'Tracy'] print classmate print len(classmat ...
- JavaScript 递归
递归是一种解决问题的方法,它解决问题的各个小部分,直到解决最初的大问题.通常涉及 函数调用自身. 能够像下面这样直接调用自身的方法或函数,是递归函数: var recursiveFunction = ...
- 0417 jQuery基础知识
jQuery基础知识 jQuery需要引入一个js文件,并且这个文件在所有js代码之前(包括引入的其他js文件) 基础操作(对比js): 1.找标签: js:document.getElement.. ...
- [LeetCode] Design Compressed String Iterator 设计压缩字符串的迭代器
Design and implement a data structure for a compressed string iterator. It should support the follow ...