博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
HDU 5533 Dancing Stars on Me 计算几何瞎暴力
阅读量:6349 次
发布时间:2019-06-22

本文共 2893 字,大约阅读时间需要 9 分钟。

Dancing Stars on Me

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)

Total Submission(s): 1184    Accepted Submission(s): 651

Problem Description
The sky was brushed clean by the wind and the stars were cold in a black sky. What a wonderful night. You observed that, sometimes the stars can form a regular polygon in the sky if we connect them properly. You want to record these moments by your smart camera. Of course, you cannot stay awake all night for capturing. So you decide to write a program running on the smart camera to check whether the stars can form a regular polygon and capture these moments automatically.
Formally, a regular polygon is a convex polygon whose angles are all equal and all its sides have the same length. The area of a regular polygon must be nonzero. We say the stars can form a regular polygon if they are exactly the vertices of some regular polygon. To simplify the problem, we project the sky to a two-dimensional plane here, and you just need to check whether the stars can form a regular polygon in this plane.
 

 

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.
1T300
3n100
10000xi,yi10000
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
 

 

Source
 

 

Recommend
hujie   |   We have carefully selected several similar problems for you:            
 
给一些点 问组成的图形是不是正的
瞎暴力一下就可以了 (其实遇到这种题基本也只会暴力
把所有点互相的距离都求出来
然后排下序 看最小的点和第n小的点是否相等就可以
 
#include 
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;#define FIN freopen("input.txt","r",stdin);#define FOUT freopen("output.txt","w",stdout);#define INF 0x3f3f3f3f#define INFLL 0x3f3f3f3f3f3f3f#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1typedef long long LL;typedef pair
PII;const int MAXN = 1e2 + 5;int T, n;int a[MAXN], b[MAXN];double dis[MAXN * MAXN];int main(){ //FIN scanf("%d", &T); while(T--) { scanf("%d", &n); for(int i = 1; i <= n; i++) { scanf("%d%d", &a[i], &b[i]); } int cas = 0; for(int i = 1; i <= n - 1; i++) { for(int j = i + 1; j <= n; j++) { dis[++cas] = (double) sqrt((a[j] - a[i])*(a[j] - a[i]) + (b[j] - b[i])*(b[j] - b[i])); } } sort(dis + 1, dis + cas + 1);// for(int i = 1; i <= cas; i++) {// cout << dis[i] << endl;// }// cout << "cas=" << cas << endl; if(dis[1] == dis[n]) printf("YES\n"); else printf("NO\n"); } return 0;}

  

转载于:https://www.cnblogs.com/Hyouka/p/5875299.html

你可能感兴趣的文章
量化交易之启航
查看>>
TX Text Control文字处理教程(3)打印操作
查看>>
CENTOS 7 如何修改IP地址为静态!
查看>>
MyCat分片算法学习(纯转)
查看>>
IO Foundation 3 -文件解析器 FileParser
查看>>
linux学习经验之谈
查看>>
mysqld_multi实现多主一从复制
查看>>
中介模式
查看>>
JS中将变量转为字符串
查看>>
servlet笔记
查看>>
JVM(五)垃圾回收器的前世今生
查看>>
CentOS 7 下安装 Nginx
查看>>
Spring Boot 自动配置之@EnableAutoConfiguration
查看>>
web前端笔记
查看>>
import 路径
查看>>
使用optimizely做A/B测试
查看>>
finally知识讲解
查看>>
Matplotlib绘图与可视化
查看>>
openstack ocata版(脚本)控制节点安装
查看>>
【微信公众号开发】获取并保存access_token、jsapi_ticket票据(可用于微信分享、语音识别等等)...
查看>>