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 ...
随机推荐
- 训练1-B
杭州人称那些傻乎乎粘嗒嗒的人为62(音:laoer). 杭州交通管理局经常会扩充一些的士车牌照,新近出来一个好消息,以后上牌照,不再含有不吉利的数字了,这样一来,就可以消除个别的士司机和乘客的心理障碍 ...
- [tyvj-2054][Nescafé29]四叶草魔杖 费用流
lyd讲的最小生成树的题. 道理我都懂,费用流多好写,又好调.但和一般费用流不一样的就是它走过一次后费用需调成0,但是再等回流,就恢复原状即可. #include <queue> #inc ...
- 《黑白团团队》第七次作业:团队项目设计完善&编码
项目 内容 作业课程地址 任课教师首页链接 作业要求 团队项目 填写团队名称 黑白团团队 填写具体目标 认真负责,完成项目 任务1:团队软件项目设计完善 Github仓库上传<软件设计方案说明书 ...
- Map 遍历的几种方法
复习map的过程中想到的,做个简单的记录 public class HashMapTest { public static void main(String args[]) { Map<Inte ...
- 全球级的分布式数据库 Google Spanner原理
开发四年只会写业务代码,分布式高并发都不会还做程序员?->>> Google Spanner简介 Spanner 是Google的全球级的分布式数据库 (Globally-Di ...
- CF922B Magic Forest
CF922B Magic Forest 题意翻译 题目大意 给定一个正整数nn ,求满足如下条件的三元组(a,b,c)(a,b,c) 的个数: 1 \le a \le b \le c \le n1≤a ...
- Java 微信公众号上传永久素材的方法
Java 微信公众号上传永久素材的方法 学习了:http://blog.csdn.net/u013791374/article/details/53258275 膜拜一下,源码如下: @Request ...
- Windows 8.1内置微软五笔输入法
微软五笔输入法採用86版编码,不是Windows 8.1系统的中文语言的缺省输入法,你在使用它之前须要把它加入到系统输入法中. 在控制面板双击"",然后加入微软五笔输入法. wat ...
- android 虚拟按键是通过哪种机制上报的?
1.在normal mode下,tp button也是和其他触摸事件一样,以坐标形式的input_event进行上报.在初始化时会通过tpd_button_setting()函数依据定义在tpd_cu ...
- awesome-free-software
Free software is distributed under terms that allow users to run the program for any purpose, study ...