博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
hdu 5533 Dancing Stars on Me(数学,水)
阅读量:6616 次
发布时间:2019-06-24

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

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.1≤T≤3003≤n≤100−10000≤xi,yi≤10000All 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
330 01 11 040 00 11 01 150 00 10 22 22 0

 

 

 

Sample Output
NO YES NO

 

 

 

Source
 
题意:给你几个点,判断这几个点能否组成正n边形
先算出两两之间的距离存于mp[][]数组,然后找出最小的距离minnn,如果mp数组刚好有n个等于minnn,则是正多边形
1 #pragma comment(linker, "/STACK:1024000000,1024000000") 2 #include
3 #include
4 #include
5 #include
6 #include
7 #include
8 #include
9 #include
10 #include
11 #include
12 #include
13 #include
14 #include
15 using namespace std;16 #define PI acos(-1.0)17 #define max(a,b) (a) > (b) ? (a) : (b)18 #define min(a,b) (a) < (b) ? (a) : (b)19 #define ll long long20 #define eps 1e-1021 #define MOD 100000000722 #define N 10623 #define inf 1<<2624 int n;25 double x[N],y[N];26 double mp[N][N];27 double cal(int i,int j){28 return ((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));29 }30 int main()31 {32 int t;33 scanf("%d",&t);34 while(t--){35 scanf("%d",&n);36 for(int i=0;i
mp[i][j]){44 minnn=mp[i][j];45 }46 }47 }48 int ans=0;49 for(int i=0;i
View Code

 

转载地址:http://urhso.baihongyu.com/

你可能感兴趣的文章
Android TextView中显示图片
查看>>
Net高并发解决思路
查看>>
Log4Net 生成多个文件、文件名累加解决方法
查看>>
ARMS 公有云 发布 V2.3.1版本, 新增 应用监控功能 等重磅功能。
查看>>
oracle 包,函数,过程,块的创建和执行及在java中执行(转)
查看>>
CloudDBA现场助力双十一
查看>>
虚拟现实技术或会产生副作用
查看>>
【云图】如何设置微信里的全国实体店地图?
查看>>
db file async I/O submit 等待事件优化
查看>>
前端需要了解的 SSO 与 CAS 知识
查看>>
李开复谈未来工作:虽然会被AI取代,但谁说人类非得工作不可?
查看>>
PostgreSQL 空间切割(st_split)功能扩展 - 空间对象网格化
查看>>
Intercom的持续部署实践:一天部署100次,1次10分钟
查看>>
Windows I/O模型、同步/异步、阻塞/非阻塞
查看>>
SpringBoot权限控制
查看>>
阿里云中间件技术 促进互联网高速发展
查看>>
智能时代悄然到来 物联网称王将引爆传感器产业
查看>>
物理隔离计算机被USB蜜蜂刺破 数据通过无线信号泄露
查看>>
利用一点机器学习来加速你的网站
查看>>
中国域名现状:应用水平较低,安全仍存隐患
查看>>