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. 【sessionInfo】使用说明

    对象:sessionInfo 说明:会话类型操作,此对象是session与cookies的完善版,解决了session异常丢失及cookies文件大小的问题. 注意: 1)  访客的IP地址发生变化时 ...

  2. C++错误:Process returned -1073741571 (0xC00000FD)

    最近写程序时,需要将一个一维数组编程二维数组,很简单,写完之后,运行错误! 提示:Process returned -1073741571 (0xC00000FD) 刚开始写的代码如下: #inclu ...

  3. [转载]CENTOS 6.0 iptables 开放端口80 3306 22端口

    原文地址:6.0 iptables 开放端口80 3306 22端口">CENTOS 6.0 iptables 开放端口80 3306 22端口作者:云淡风轻 #/sbin/iptab ...

  4. Python3 数值类型与运算符

    1.数值类型与进制 (1)基本类型 整型:int 浮点型:float 布尔类型:bool 复数:complex print(type(1)) print(type(1.1)) print(type(F ...

  5. POJ 3487 The Stable Marriage Problem(稳定婚姻问题 模版题)

    Description The stable marriage problem consists of matching members of two different sets according ...

  6. BluetoothAdapter解析

    这篇文章将会详细解析BluetoothAdapter的详细api, 包括隐藏方法, 每个常量含义. 一 BluetoothAdapter简介 1.继承关系 该类仅继承了Object类; 2.该类作用 ...

  7. 2d命令行小游戏源码

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...

  8. UVALive - 6864 Strange Antennas 扫描线

    题目链接: http://acm.hust.edu.cn/vjudge/problem/87213 Strange Antennas Time Limit: 3000MS 题意 一个雷达能够辐射到的范 ...

  9. iOS如何做出炫酷的翻页效果

    详情链接http://www.jianshu.com/p/b6dc2595cc3e https://github.com/schneiderandre/popping

  10. MVC4+EF5 edmx代码分析

    本文分析Entity Framework(EF)从数据库自动生成的模型文件代码(扩展名为edmx). 一. 概述 本文使用的数据库结构尽量简单,只有2个表,一个用户表和一个分公司表(相当于部门表),一 ...