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) ...
随机推荐
- LeetCode 108——将有序数组转化为二叉搜索树
1. 题目 2. 解答 一棵高度平衡的二叉搜索树意味着根节点的左右子树包含相同数量的节点,也就是根节点为有序数组的中值. 因此,我们将数组的中值作为根节点,然后再递归分别得到左半部分数据转化的左子树和 ...
- UVa 1225 - Digit Counting - ACM/ICPC Danang 2007 解题报告 - C语言
1.题目大意 把前n$(n\le 10000)$个整数顺次写在一起:12345678910111213……计算0~9各出现了多少次. 2.思路 第一想法是打表,然而觉得稍微有点暴力.不过暂时没有想到更 ...
- 脚本 script 常用脚本
目录 remove_all_pyc find_all_links rename_with_slice load_json_without_dupes execution_time benchmark_ ...
- 5.hadoop常用命令
1. 单独启动和关闭hadoop服务 启动名称节点 #hadoop-daemon.sh start namenode 启动数据节点 #hadoop-daemons.sh start datanode ...
- 十二:NodeManager
NM负责启动和管理节点上的containers.AM通过containers来运行任务. Health Checker Service 创建检查服务 NM运行一个检查服务来检查节点的状态,该服 ...
- codeforces 295C Greg and Friends(BFS+DP)
One day Greg and his friends were walking in the forest. Overall there were n people walking, includ ...
- Java学习个人备忘录之内部类
内部类: 将一个类定义在另一个类的里面,对里面那个类就称为内部类. class Outer { private int num = 3; class Inner //它想访问Outer中的num, 如 ...
- freefcw/hustoj Install Guide
First of all, this version hustoj is a skin and improved for https://code.google.com/p/hustoj/. So t ...
- SpringMVC拦截器实现登录认证(转发)
感谢原作者,转发自:http://blog.csdn.net/u014427391/article/details/51419521 以Demo的形式讲诉拦截器的使用 项目结构如图: 需要的jar:有 ...
- PAT 甲级 1048 Find Coins
https://pintia.cn/problem-sets/994805342720868352/problems/994805432256675840 Eva loves to collect c ...