hdu 5563 Clarke and five-pointed star 【BestCoder Round #62 (div.2) 1002】

Click here ~~

Clarke and five-pointed star

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 242    Accepted Submission(s): 144

Problem Description

Clarke is a patient with multiple personality disorder. One day, Clarke turned into a learner of geometric. 
When he did a research with polygons, he found he has to judge if the polygon is a five-pointed star at many times. There are 5 points on a plane, he wants to know if a five-pointed star existed with 5 points given.

 

Input

The first line contains an integer T(1≤T≤10),
the number of the test cases. 
For each test case, 5 lines follow. Each line contains 2 real numbers xi,yi(−109≤xi,yi≤109),
denoting the coordinate of this point.

 

Output

Two numbers are equal if and only if the difference between them is less than 10−4. 
For each test case, print Yes if
they can compose a five-pointed star. Otherwise, print No.
(If 5 points are the same, print Yes.
)

 

Sample Input


2
3.0000000 0.0000000
0.9270509 2.8531695
0.9270509 -2.8531695
-2.4270509 1.7633557
-2.4270509 -1.7633557
3.0000000 1.0000000
0.9270509 2.8531695
0.9270509 -2.8531695
-2.4270509 1.7633557
-2.4270509 -1.7633557

 

Sample Output


Yes
No

Hint

 

Source

BestCoder Round #62 (div.2)

 

题目大意:

克拉克是一名人格分裂患者。某一天克拉克分裂为一个几何学习者,在研究多边形。
在研究某一个多边形的时候,克拉克发现他多次遇到判断5个点是否能组成一个五角星的问题,在这里,这5个点分别代表五角星的五个顶点(顶角上的点)。于是他跑来想你求助,让你写出一个程序快速判定。即对于给出的5个点,判断这5个点是否能组成一个五角星。

官方题解:

容易看出只需要判断这5个点是否在一个正五边形上。

因此我们枚举排列,然后依次判断即可。

判定方法是,五条相邻边相等,五条对角线相等。

当然题目给的精度问题,窝只能说,如果泥做法不复杂,精度足够好的话,是可以过的。毕竟题目说的小于10^{-4}10​−4​​是指理论上的,所以理论上适用所有的数之间的比较。所以有人问我开方前和开方后,我只能说,哪个精度高用哪个....

当然你也可以先求出凸包然后再判相邻距离......

个人看法:

就是把每条边算一下就好了,后来感觉不是很对,以为还要算一下角度,以为错了,但是竟然对了,嘿嘿,上代码:

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>
#include <algorithm>
#include <set>
using namespace std;

#define MM(a) memset(a,0,sizeof(a))

typedef long long LL;
typedef unsigned long long ULL;
const int maxn = 1e3+5;
const int mod = 1000000007;
const double eps = 1e-4;
LL gcd(LL a, LL b)
{
    if(b == 0)
        return a;
    return gcd(b, a%b);
}
struct node
{
    double x,y;
} p[25];
double d[30];
double dis(node p1, node p2)
{
    return sqrt((p1.x-p2.x)*(p1.x-p2.x) + (p1.y-p2.y)*(p1.y-p2.y));
}
int check()
{
    for(int i=0; i<4; i++)
        if(d[i+1]-d[i] > eps)
            return 0;
    return 1;
}
int main()
{
    int k, T;
    scanf("%d",&T);
    while(T--)
    {
        k=0;
        for(int i=0; i<5; i++)
            scanf("%lf%lf",&p[i].x,&p[i].y);
        for(int i=0; i<5; i++)
            for(int j=i+1; j<5; j++)
                d[k++] = dis(p[i],p[j]);
        sort(d, d+10);
        if(check())
            printf("Yes\n");
        else
            printf("No\n");
    }
    return 0;
}
时间: 2024-10-31 02:32:42

hdu 5563 Clarke and five-pointed star 【BestCoder Round #62 (div.2) 1002】的相关文章

hdu 5500 Reorder the Books 【BestCoder Round #59 (div.2) 第二题】

Reorder the Books Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) Total Submission(s): 244    Accepted Submission(s): 168 Problem Description dxy has a collection of a series of books called "The Stories of SDOI&

hdu 5499 SDOI 【BestCoder Round #59 (div.2) 】

SDOI Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) Total Submission(s): 298    Accepted Submission(s): 117 Problem Description The Annual National Olympic of Information(NOI) will be held.The province of Shando

hdu 5523 Game 【BestCoder Round #61 (div.2)】

Game Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) Total Submission(s): 315    Accepted Submission(s): 126 Problem Description XY is playing a game:there are N pillar in a row,which numbered from 1 to n.Each pi

hdu 5464 Clarke and problem (BestCoder Round #56 (div.2))

Clarke and problem Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 350    Accepted Submission(s): 151 Problem Description Clarke is a patient with multiple personality disorder. One day, Clarke

hdu 5463 Clarke and minecraft(BestCoder Round #56 (div.2))

Clarke and minecraft Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 314    Accepted Submission(s): 163 Problem Description Clarke is a patient with multiple personality disorder. One day, Clar

hdu 5504 GT and sequence【BestCoder Round #60 】

GT and sequence Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 1441    Accepted Submission(s): 336 Problem Description You are given a sequence of N integers. You should choose some numbers(at

hdu 5505 GT and numbers【BestCoder Round #60】

GT and numbers Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 1066    Accepted Submission(s): 285 Problem Description You are given two numbers N and M. Every step you can get a new N in the w

Codeforces 591 B Rebranding【Codeforces Round #327 (Div. 2)】

B. Rebranding time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output The name of one small but proud corporation consists of n lowercase English letters. The Corporation has decided to try rebran

Codeforces 400 B. Inna and New Matrix of Candies 【 Codeforces Round #234 (Div. 2)】

B. Inna and New Matrix of Candies time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Inna likes sweets and a game called the "Candy Matrix". Today, she came up with the new game "Can