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 ...
随机推荐
- IDEA热部署配置
一.IDEA热加载的作用: 热加载的作用就是当你保存修改,新增,删除代码或者文件后,不需要重新启动项目,直接就能运行. 二.IDEA热记载的配置方法 1.配置pom文件,加载依赖 Maven. < ...
- [USACO12MAR]摩天大楼里的奶牛Cows in a Skyscraper (状态压缩DP)
不打算把题目放着,给个空间传送门,读者们自己去看,传送门(点我) . 这题是自己做的第一道状态压缩的动态规划. 思路: 在这题中,我们设f[i]为i在二进制下表示的那些牛所用的最小电梯数. 设g ...
- Top English interview Q&A
http://www.hjenglish.com/new/p581292/ vocabulary endeavour [ɪn'devər] relevant ['reləvənt] , efficie ...
- Acdream A - Unique Attack
A - Unique Attack Time Limit: 6000/3000MS (Java/Others) Memory Limit: 128000/64000KB (Java/Others) ...
- 深入MNIST code测试
本系列文章由 @yhl_leo 出品,转载请注明出处. 文章链接: http://blog.csdn.net/yhl_leo/article/details/50624471 依照教程:深入MNIST ...
- CentOs下安装图形界面
CentOS6的图形界面对计算机的内存有要求,应该是要大于512M吧,如果不满足这个条件 在安装的时候,图形界面是不会安装的,可以在linux系统安装完毕后,进入命令后再次安装图形界面 安装图形界面有 ...
- json_encode把中文字符的数组转为json格式
function ch_json_encode($data) { /** * 将中文编码 * @param array $data * @returnstring */ function ch_url ...
- cogs 106. [NOIP2003] 加分二叉树(区间DP)
106. [NOIP2003] 加分二叉树 ★☆ 输入文件:jfecs.in 输出文件:jfecs.out 简单对比时间限制:1 s 内存限制:128 MB [问题描述] 设 一个 n ...
- [using_microsoft_infopath_2010]Chapter10 与SharePoint Designer工作流集成
本章概要: 1.创建工作流集成表单 2.允许工作流手动触发 3.创建自定义动作按钮 4.使用人物设计器 5.维护工作流人物表单
- Grace Hopper 葛丽丝 霍普
Grace Murray Hopper(1906-1992), COBOL之母, Debug之母, A ship in port is safe, but that is not what ships ...