HDU5533(水不水?)
Dancing Stars on Me
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)
Total Submission(s): 286 Accepted Submission(s): 185
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.
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≤300
3≤n≤100
−10000≤xi,yi≤10000
All coordinates are distinct.
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
YES
NO
{
if(a.x>b.x)
return true;
if(a.x==b.x)
{
if(a.y>b.y)
return true;
}
return false;
}
#include<bits/stdc++.h>
using namespace std;
int t;
int n;
struct node
{
double x;
double y;
}N[105];
double dis(int x1,int y1,int x2,int y2)
{
return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}
bool cmp(struct node a,struct node b)
{
if(a.x>b.x)
return true;
if(a.x==b.x)
{
if(a.y>b.y)
return true;
}
return false;
}
int main()
{
scanf("%d",&t);
for(int i=1;i<=t;i++)
{
memset(N,0,sizeof(N));
scanf("%d",&n);
for(int j=0;j<n;j++)
scanf("%lf%lf",&N[j].x,&N[j].y);
if(n!=4)
printf("NO\n");
else
{
sort(N,N+4,cmp);
int dis1,dis2,dis3,dis4,ss1,ss2,ss3;
dis1=dis(N[0].x,N[0].y,N[1].x,N[1].y);
dis2=dis(N[2].x,N[2].y,N[3].x,N[3].y);
dis3=dis(N[0].x,N[0].y,N[2].x,N[2].y);
dis4=dis(N[1].x,N[1].y,N[3].x,N[3].y);
ss1=(N[0].x-N[1].x)*(N[0].x-N[1].x)+(N[0].y-N[1].y)*(N[0].y-N[1].y);
ss2=(N[0].x-N[2].x)*(N[0].x-N[2].x)+(N[0].y-N[2].y)*(N[0].y-N[2].y);
ss3=(N[1].x-N[2].x)*(N[1].x-N[2].x)+(N[1].y-N[2].y)*(N[1].y-N[2].y);
if(dis1==dis2&&dis2==dis3&&dis3==dis4&&((ss1+ss2)==ss3))
printf("YES\n");
else
printf("NO\n");
}
} return 0;
}
HDU5533(水不水?)的更多相关文章
- 桶装水 送水 消费充值PDA会员管理系统 介绍
桶装水 送水 消费充值PDA会员管理系统 介绍 主要功能:会员管理临时开卡.新增会员.修改会员.删除会员场馆管理仓管信息管理.租凭信息管理会员卡管理会员卡类型设置.会员发卡.会员信息管理.体验用户发卡 ...
- 两个和尚抬水有水喝,三个和尚抬水没水喝------IT项目管理之组织架构
说到项目经理岗位,一般的想法是,一个项目只能有一个项目经理,否则责任不明,互相推诿.偏偏IT项目需要有两个甚至三个项目经理.原因何在呢? 典型的IT项目(不包含纯技术或工具类项目)是把用户的需求转化成 ...
- 某寺庙,有小和尚、老和尚若干。有一水缸,由小和尚用水桶从井中提水入缸,老和尚用水桶从缸里取水饮用。水缸可容10桶水,水取自同一井中。水井径窄,每次只能容一个水桶取水。水桶总数为3个。每次入、取缸水仅为1桶,且不可以同时进行。试用P、V操作给出小和尚、老和尚动作的算法描述。
寺庙和尚打水 设信号量mutex_gang, mutex_jing, gang_empty, gang_full, count分别表示使用缸互斥, 使用井互斥, 缸空, 缸满, 水桶总个数 semap ...
- [BZOJ1601][Usaco2008 Oct]灌水 最小生成树水题
1601: [Usaco2008 Oct]灌水 Time Limit: 5 Sec Memory Limit: 162 MBSubmit: 2121 Solved: 1393[Submit][St ...
- HDU 1040.As Easy As A+B【排序】【如题(水!水!水!)】【8月24】
As Easy As A+B Problem Description These days, I am thinking about a question, how can I get a probl ...
- “盛大游戏杯”第15届上海大学程序设计联赛夏季赛暨上海高校金马五校赛题解&&源码【A,水,B,水,C,水,D,快速幂,E,优先队列,F,暴力,G,贪心+排序,H,STL乱搞,I,尼姆博弈,J,差分dp,K,二分+排序,L,矩阵快速幂,M,线段树区间更新+Lazy思想,N,超级快速幂+扩展欧里几德,O,BFS】
黑白图像直方图 发布时间: 2017年7月9日 18:30 最后更新: 2017年7月10日 21:08 时间限制: 1000ms 内存限制: 128M 描述 在一个矩形的灰度图像上,每个 ...
- hdu_1037(水题水疯了。。。史上最水)
#include<cstdio> #include<cstring> #include<algorithm> using namespace std; int ma ...
- ZOJ 3846 GCD Reduce//水啊水啊水啊水
GCD Reduce Time Limit: 2 Seconds Memory Limit: 65536 KB Special Judge You are given a sequ ...
- HDU 5538 (水不水?)
House Building Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others) ...
随机推荐
- centos 6.5 启动时卡在进度条位置无法进入系统解决办法。
今天公司服务器因突然断电导致phddns 花生壳 启动失败,一直卡在启动进度条页面. 解决办法 1.按F5查看卡在什么位置, 2.查看解决方法:程序卡住的情况下,直接备份资料后,卸载程序重启就可以了. ...
- 我的linux操作习惯
标签(空格分隔): ubuntu 最佳操作 用linux随时可能会有宕机的危险,谁知道我哪会神经病犯了呢.用deepin宕机的可能性会更高的,所以我才不得不安装一个windows做备份,然后把数据备份 ...
- Python3 Tkinter-PaneWindow
1.向PanedWindow中添加Pane from tkinter import * root=Tk() panes=PanedWindow(orient=VERTICAL) panes.pack( ...
- HDU 1042 N!(高精度乘)
Problem Description Given an integer N(0 ≤ N ≤ 10000), your task is to calculate N! Input One N in ...
- Spring Boot(五)启动流程分析
学习过springboot的都知道,在Springboot的main入口函数中调用SpringApplication.run(DemoApplication.class,args)函数便可以启用Spr ...
- Tomcat启动报错ERROR:transport error 202:bind failed:Address already
昨天在服务器上拷贝了一个tomcat项目,修改了server.xml之后启动居然报错ERROR:transport error 202:bind failed:Address already,应该是远 ...
- 第68天:原型prototype方法
一.原型prototype方法声明 构造函数有一个prototype属性,指向实例对象的原型对象.通过同一个构造函数实例化的多个对象具有相同的原型对象.经常使用原型对象来实现继承 <!DOCTY ...
- WPF通过NPIO读写Excel操作
自已摸索实现了对excel简单的上传和下载并做了一个封装类,下面分享一下. 先去官网:http://npoi.codeplex.com/下载需要引入dll(可以选择.net2.0或者.net4.0的d ...
- RT-thread内核之线程调度算法
一个操作系统如果只是具备了高优先级任务能够“立即”获得处理器并得到执行的特点,那么它仍然不算是实时操作系统.因为这个查找最高优先级线程的过程决定了调度时间是否具有确定性,例如一个包含n个就绪任务的系统 ...
- 【bzoj2223】[Coci 2009]PATULJCI 主席树
题目描述 样例输入 10 3 1 2 1 2 1 2 3 2 3 3 8 1 2 1 3 1 4 1 5 2 5 2 6 6 9 7 10 样例输出 no yes 1 no yes 1 no yes ...