HDU 5533 Dancing Stars on Me( 有趣的计算几何 )
**链接:****传送门 **
题意:给出 n 个点,判断能不能构成一个正 n 边形,这 n 个点坐标是整数
思路:这道题关键就在与这 n 个点坐标是正整数!!!可以简单的分析,如果 n != 4,那一定就不能构成正 n 边形,否则暴力一下找到最小距离,这个最小距离一定是最短边长,暴力查找一下等于这个边长边的个数,如果是 4 个就能构成正 4 边形了
balabala:
- 分析 + 暴力出奇迹,出题人还是蛮有趣的!希望能在比赛中get到这些关键点。
- A strong man will struggle with the storms of fate.
/*************************************************************************
> File Name: hdu5533.cpp
> Author: WArobot
> Blog: http://www.cnblogs.com/WArobot/
> Created Time: 2017年05月10日 星期三 19时33分30秒
************************************************************************/
#include<bits/stdc++.h>
using namespace std;
struct point{
int x,y;
}po[110];
double len[110][110];
int T,n;
double dis(point a,point b){
return (a.x-b.x)*(a.x-b.x) + (a.y-b.y)*(a.y-b.y);
}
int main(){
scanf("%d",&T);
while(T--){
memset(len,0,sizeof(len));
scanf("%d",&n);
for(int i=0;i<n;i++){
scanf("%d%d",&po[i].x,&po[i].y);
}
if(n!=4) printf("NO\n");
else{
double min_len = 1e10;
for(int i=0;i<n;i++)
for(int j=i+1;j<n;j++){
len[i][j] = dis( po[i], po[j] );
min_len = min( min_len , len[i][j] );
}
int cnt = 0;
for(int i=0;i<n;i++)
for(int j=i+1;j<n;j++)
if( len[i][j] == min_len )
cnt++;
if(cnt == 4) printf("YES\n");
else printf("NO\n");
}
}
return 0;
}
HDU 5533 Dancing Stars on Me( 有趣的计算几何 )的更多相关文章
- 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 5533 Dancing Stars on Me 水题
Dancing Stars on Me Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.p ...
- 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 ...
- 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/ 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 ...
- Dancing Stars on Me(判断正多边形)
Dancing Stars on Me Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Ot ...
- [hdu 6184 Counting Stars(三元环计数)
hdu 6184 Counting Stars(三元环计数) 题意: 给一张n个点m条边的无向图,问有多少个\(A-structure\) 其中\(A-structure\)满足\(V=(A,B,C, ...
- hdu 5533
Dancing Stars on Me Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Ot ...
- hdu 5533 正n边形判断 精度处理
Dancing Stars on Me Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Ot ...
随机推荐
- JAVA学习之枚举
1.新建一个枚举类 public enum Apple{ FUJI, PIPPIN, GRANNY_SMITH } 通过查看字节码,可以看到,枚举类的实现方式: 1)继承自java.lang.Enum ...
- springboot实现拦截器
你首先需要一个搭建好的springboot项目,具体怎么搭建我还没有相应的随笔可以交给你,可以自己上网上看一下,学习一下,之后我要是总结出来的话,这里面我会通知的 首先这个项目的目录结构是这样子的 首 ...
- XML文件基础
https://c3d.club/xml/basic/2018/12/27/xml-file-base.html 1.文件头 XML文件头有XML声明与DTD文件类型声明组成.其中DTD文件类型声 ...
- 【Codeforces Round #505 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Final) A】 Doggo Recoloring
[链接] 我是链接,点我呀:) [题意] 你可以把出现次数大于1的颜色换成其他颜色. 问你最后能不能全都变成同一种颜色 [题解] 判断一下有没有出现次数大于1的就好. 有的话.显然可以一直用它变颜色. ...
- js 阻止冒泡
$this.click(function(e){ e.stopPropagation(); });
- SecureRandom生成随机数超慢 导致tomcat启动时间过长的解决办法
用腾讯云的CentOS 7.2 CVM 服务器跑Tomcat时发现,Tomcat启动的特别慢,通过查看日志,发现时间主要花在实例化SecureRandom对象上了. 由该日志可以看出,实例化该对象使用 ...
- spring boot不同环境读取不同配置
具体做法: 不同环境的配置设置一个配置文件,例如:dev环境下的配置配置在application-dev.properties中:prod环境下的配置配置在application-prod.prope ...
- Linux中在主机上实现对备机上文件夹及文件的操作的C代码实现
需求描写叙述 编敲代码.完毕在主机上实现对备机上文件夹及文件的操作. 比如,主机为A,备机为B,要求编写的程序运行在A机上,该程序实如今B机上创建文件文件夹及复制文件的操作. 需求分析 我们先不考虑用 ...
- jboss final 7.1.1相关error以及解决方式
问题1 报错提示: MSC00001: Failed to start service jboss.web.deployment.default-host./: Caused by: java.lan ...
- Linux 技巧:让进程在后台可靠执行的几种方法
我们常常会碰到这种问题.用 telnet/ssh 登录了远程的 Linux server,执行了一些耗时较长的任务, 结果却因为网络的不稳定导致任务中途失败.怎样让命令提交后不受本地关闭终端窗体/网络 ...