博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Dancing Stars on Me(判断正多边形)
阅读量:6640 次
发布时间:2019-06-25

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

Dancing Stars on Me

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others) Total Submission(s): 592    Accepted Submission(s): 315

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
 

题意:给你一个多边形,问你这个多边形是否是正多边形。。。

题解:无奈啊,我刚开始就判断边是否相等,用差集排序,相邻判断,果断wa,又想着没考虑角度,就想着对相邻两个边求差集,是否相等,各种wa,无耐加心碎啊,然后就暴力了了。。。就判断个相等边都要大于等于2,然后就对了。。。fuck。。。

代码:

#include
#include
#include
#include
#include
#include
#include
using namespace std;#define mem(x,y) memset(x,y,sizeof(x))#define SI(x) scanf("%d",&x)#define SL(x) scanf("%lld",&x)#define PI(x) printf("%d",x)#define PL(x) printf("%lld",x)#define P_ printf(" ")#define T_T while(T--)typedef long long LL;const int INF=0x3f3f3f3f;const int MAXN=210;int N;struct Node{ LL x,y; /*Node(LL x=0,LL y=0):x(x),y(y){}*/};Node dt[MAXN];/*LL cross(Node a,Node b){ return a.x*b.y-a.y*b.x;}int cmp(Node a,Node b){ if(cross(a,b)>=0)return 1; else return 0;}*//*Node operator - (Node a,Node b){ return Node(a.x-b.x,a.y-b.y);}*/double getl(Node a,Node b){ LL x=a.x-b.x,y=a.y-b.y; return sqrt(1.0*x*x+1.0*y*y);}bool judge(){ //double temp=getl(dt[0],dt[N-1]); double ans; for(int i=0;i

  

 

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

你可能感兴趣的文章
运维老鸟教你安装centos6.5如何选择安装包
查看>>
终于解决了一个Win7 下 VS 编译的问题,困扰了我好几个月
查看>>
企业级nginx基础、负载、读写分离技术(续一)
查看>>
利用DBMS_ADVISOR.TUNE_MVIEW包生成物化视图创建语句
查看>>
系统安装EMC多路径软件
查看>>
Web前端——Head区域代码规范
查看>>
我认为的android入门学习策略
查看>>
ssh服务配置
查看>>
Windows 8 异步编程
查看>>
XenDesktop项目的规划
查看>>
RDS Best Practices — Fast and Stable Migration to RDS
查看>>
C# 进程间通信(共享内存)
查看>>
jvm(13)-线程安全与锁优化(转)
查看>>
thinkphp学习笔记4—眼花缭乱的配置
查看>>
ibwebrtc-audio-processing-devel
查看>>
密码复杂度检查的正则表达式
查看>>
设置 CxImage 的 Alpha 透明度
查看>>
“先体检,再治病“ 迪普科技为某金融企业量身定制安全方案
查看>>
UIT创新科:大力护盘自主可控高效存储
查看>>
为什么数据中心需要使用VMware NSX?
查看>>