HDU 5533/ 2015长春区域 G.Dancing Stars on Me 暴力

Dancing Stars on Me

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

题意:给你n个点(整点),问你这n个点能否组成正n边形

题解:因为是整点,所有只能是正方形,判断就是了

///1085422276
#include<bits/stdc++.h>
using namespace std ;
typedef long long ll;
#define mem(a) memset(a,0,sizeof(a))
#define meminf(a) memset(a,127,sizeof(a));

inline ll read()
{
    ll x=0,f=1;char ch=getchar();
    while(ch<‘0‘||ch>‘9‘){
        if(ch==‘-‘)f=-1;ch=getchar();
    }
    while(ch>=‘0‘&&ch<=‘9‘){
        x=x*10+ch-‘0‘;ch=getchar();
    }return x*f;
}
//****************************************

const int inf=9999999;
#define maxn 150
struct node
{
    int x;
    int y;
}p[maxn];
int  d[8];
int n,x[maxn],y[maxn];
int  dis(node a,node b)
{
    return (a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y);
}
bool test()
{
    int ans=inf;
    d[0]=dis(p[0],p[1]);
    d[1]=dis(p[1],p[2]);
    d[2]=dis(p[2],p[3]);
    d[3]=dis(p[3],p[0]);
    d[4]=dis(p[0],p[2]);
    d[5]=dis(p[1],p[3]);
    sort(d,d+6);
    if(d[0]==d[1]&&d[1]==d[2]&&d[2]==d[3]&&2*d[3]==d[4]&&d[4]==d[5])
    {
        return 1;
    }
    return 0;
}
int main(){
    int T=read();
    while(T--){
        scanf("%d",&n);
        for(int i=0;i<n;i++){
            scanf("%d%d",&x[i],&y[i]);
        }
        if(n!=4){
            cout<<"NO"<<endl;
        }
        else {
            for(int i=0;i<4;i++){
                node aa;
                aa.x=x[i],aa.y=y[i];
                p[i]=aa;
            }
            if(test())cout<<"YES"<<endl;
            else cout<<"NO"<<endl;
        }
    }
  return 0;
}

代码

时间: 2024-11-08 11:52:52

HDU 5533/ 2015长春区域 G.Dancing Stars on Me 暴力的相关文章

Travel(HDU 5441 2015长春区域赛 带权并查集)

Travel Time Limit: 1500/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 2404    Accepted Submission(s): 842 Problem Description Jack likes to travel around the world, but he doesn’t like to wait. Now, he is tr

HDU 5538/ 2015长春区域 L.House Building 水题

题意:求给出图的表面积,不包括底面 ///1085422276 #include<bits/stdc++.h> using namespace std ; typedef long long ll; #define mem(a) memset(a,0,sizeof(a)) #define meminf(a) memset(a,127,sizeof(a)); #define TS printf("111111\n"); #define FOR(i,a,b) for( int

hdu 5443 (2015长春网赛G题 求区间最值)

求区间最值,数据范围也很小,因为只会线段树,所以套了线段树模板=.= Sample Input3110011 151 2 3 4 551 21 32 43 43 531 999999 141 11 22 33 3 Sample Output1002344519999999999991 1 # include <iostream> 2 # include <cstdio> 3 # include <cstring> 4 # include <algorithm>

2015长春区域赛赛后总结

比赛时间:2015.10.18 队名:哆啦小黄埋(alone kampai UMR) 成员:ST,QL,WC 解出题目:两道 网络赛的时候并没有出线,老师争取到了女队名额,才有了参加区域赛的机会(谢谢老师么么哒~ 这次的比赛打铁没有什么可怨的,实力不足+比赛策略不当+心里素质差,每一条都是超级致命的(哭 过了的两道水题,L和F,L是经过ST和WC讨论之后1A的,F是我和ST讨论过敲得,ST去看其他题,而我就在一直卡题.由于代码奇葩,队友都看不懂,只能干着急+出数据,所以只能自己调试,WA好多发,

hdu 5446(2015长春网络赛J题 Lucas定理+中国剩余定理)

题意:M=p1*p2*...pk:求C(n,m)%M,pi小于10^5,n,m,M都是小于10^18. pi为质数 M不一定是质数 所以只能用Lucas定理求k次 C(n,m)%Pi最后会得到一个同余方程组x≡B[0](mod p[0])x≡B[1](mod p[1])x≡B[2](mod p[2])......解这个同余方程组 用中国剩余定理 Sample Input19 5 23 5 Sample Output6 1 # include <iostream> 2 # include <

2015ACM/ICPC亚洲区长春站 G hdu 5533 Dancing Stars on Me

Dancing Stars on Me Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 186    Accepted Submission(s): 124 Problem Description The sky was brushed clean by the wind and the stars were cold in a bl

HDU 5533 Dancing Stars on Me 计算几何瞎暴力

Dancing Stars on Me Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 1184    Accepted Submission(s): 651 Problem Description The sky was brushed clean by the wind and the stars were cold in a b

2015年ACM长春区域赛比赛感悟

距离长春区域赛结束已经4天了,是时候整理一下这次比赛的点点滴滴了. 也是在比赛前一周才得到通知要我参加长春区域赛,当时也是既兴奋又感到有很大的压力,毕竟我的第一场比赛就是区域赛水平,还是很有挑战性的.在接到通知后,我便开始临阵抱佛脚,课也不怎么听了,上课把时间全都用在了看各种算法上,回到实验室便整理模板.开cf练手.在去比赛前,已经将所看过的算法模板都整理好了. 周五上午9点三刻左右,我们便出发了,需要经历12个小时才能到达我们此次的目的地——长春,途中我还将计算几何稍微看了一下.直到晚上11点

hdu 5533 正n边形判断 精度处理

Dancing Stars on Me Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 1098    Accepted Submission(s): 598 Problem Description The sky was brushed clean by the wind and the stars were cold in a b