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

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≤300

3≤n≤100

−10000≤xi,yi≤10000

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
题意:t 组数组 给你n个点  接着n组坐标(必须是整数)orzzz  判断 能否组成正多边形!!
 
题意说是每个点都是整数  说明只有正方形 才能满足
 
学长讲了之后 现在补  就是简单的判断 4个点能否组成正方形
 
GG 一次过了
判断 四边是否相等 并且判断一个直角
判断之前 有一个排序过程
 
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;
}
 
 
#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(水不水?)的更多相关文章

  1. 桶装水 送水 消费充值PDA会员管理系统 介绍

    桶装水 送水 消费充值PDA会员管理系统 介绍 主要功能:会员管理临时开卡.新增会员.修改会员.删除会员场馆管理仓管信息管理.租凭信息管理会员卡管理会员卡类型设置.会员发卡.会员信息管理.体验用户发卡 ...

  2. 两个和尚抬水有水喝,三个和尚抬水没水喝------IT项目管理之组织架构

    说到项目经理岗位,一般的想法是,一个项目只能有一个项目经理,否则责任不明,互相推诿.偏偏IT项目需要有两个甚至三个项目经理.原因何在呢? 典型的IT项目(不包含纯技术或工具类项目)是把用户的需求转化成 ...

  3. 某寺庙,有小和尚、老和尚若干。有一水缸,由小和尚用水桶从井中提水入缸,老和尚用水桶从缸里取水饮用。水缸可容10桶水,水取自同一井中。水井径窄,每次只能容一个水桶取水。水桶总数为3个。每次入、取缸水仅为1桶,且不可以同时进行。试用P、V操作给出小和尚、老和尚动作的算法描述。

    寺庙和尚打水 设信号量mutex_gang, mutex_jing, gang_empty, gang_full, count分别表示使用缸互斥, 使用井互斥, 缸空, 缸满, 水桶总个数 semap ...

  4. [BZOJ1601][Usaco2008 Oct]灌水 最小生成树水题

    1601: [Usaco2008 Oct]灌水 Time Limit: 5 Sec  Memory Limit: 162 MBSubmit: 2121  Solved: 1393[Submit][St ...

  5. 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 ...

  6. “盛大游戏杯”第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 描述 在一个矩形的灰度图像上,每个 ...

  7. hdu_1037(水题水疯了。。。史上最水)

    #include<cstdio> #include<cstring> #include<algorithm> using namespace std; int ma ...

  8. ZOJ 3846 GCD Reduce//水啊水啊水啊水

    GCD Reduce Time Limit: 2 Seconds      Memory Limit: 65536 KB      Special Judge You are given a sequ ...

  9. HDU 5538 (水不水?)

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

随机推荐

  1. JAVA基础学习之路(二)方法定义,重载,递归

    一,方法的定义: package test; public class test1 { public static void main(String args[]) { int result = ad ...

  2. Android开发-API指南-<path-permission>

    <path-permission> 英文原文:http://developer.android.com/guide/topics/manifest/path-permission-elem ...

  3. java学习笔记-9.违例差错控制

      1.违例规范是告诉程序员这个方法可能抛出哪些类型的异常.他的格式在方法声明中,位于自变量(参数)列表的后面,如void f() throws tooBig, tooSmall, divZero { ...

  4. 【zabbix 监控】第一章 zabbix的安装配置

    安装前准备 一.下载网络yum源: http://mirrors.163.com/.help/centos.html https://opsx.alibaba.com/mirror 1.首先备份/et ...

  5. POJ 2177 Ghost Busters(三维几何)

    Description The famous Ghost Busters team has decided to upgrade their Ectomobile (aka Ecto-1) with ...

  6. POJ 3608 Bridge Across Islands(计算几何の旋转卡壳)

    Description Thousands of thousands years ago there was a small kingdom located in the middle of the ...

  7. 关于智能指针类型shared_ptr的计数问题

    一.关键 每个shared_ptr所指向的对象都有一个引用计数,它记录了有多少个shared_ptr指向自己 shared_ptr的析构函数:递减它所指向的对象的引用计数,如果引用计数变为0,就会销毁 ...

  8. ACM 第七天

    水题 B - Minimum’s Revenge There is a graph of n vertices which are indexed from 1 to n. For any pair ...

  9. LintCode-378.将二叉查找树转换成双链表

    将二叉查找树转换成双链表 将一个二叉查找树按照中序遍历转换成双向链表. 样例 给定一个二叉查找树: 返回 1<->2<->3<->4<->5. 标签 链 ...

  10. 【week5】psp

    本周psp psp饼图: 随笔字数折线图: 代码行折线图: