hdu5563 ( Clarke and five-pointed star )

原创 2015年11月18日 17:34:36
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
using namespace std;
//point
const double eps = 1e-8;
const double PI = acos(-1.0);
int sgn(double x) {
    if(fabs(x)<eps) return 0;
    if(x < 0) return -1;
    else return 1;
}
struct Point{
    double x, y;
    Point() {}
    Point(double _x, double _y){
        x = _x; y = _y;
    }
    Point operator -(const Point& b)const {
        return Point(x - b.x, y-b.y);
    }
    double operator ^(const Point& b)const {
        return x*b.y-y*b.x;
    }
    double operator *(const Point& b)const {
        return x*b.x+y*b.y;
    }
    int operator ==(const Point& b)const{  //精度处理   判断两点是否相等 
        return !(sgn(x-b.x)&&sgn(y-b.y));
    }

    void transXY(double B){
        double tx = x, ty = y;
        x = tx*cos(B)-ty*sin(B);
        y = tx*sin(B)+ty*cos(B);
    }
};
double dist(Point a, Point b){
    return sqrt((a-b)*(a-b));
}

bool jg(Point* P,int n){
    int a[5] = {0, 1, 2, 3, 4};
    do{
        int ok = 1; 
        double bz1 = dist(P[a[0]], P[a[2]]); 
        for(int i = 1; i < 5; i++){
            if(fabs(bz1-dist(P[a[i]], P[a[(i+2)%5]]))>=1e-4)//比较他们的对角线长度
            {    
                    ok = 0;
                    break;
            }
        }
        double bz2 = dist(P[a[0]], P[a[1]]);
        for(int i = 1; i < 5; i++){
            if(fabs(bz2-dist(P[a[i]], P[a[(i+1)%5]]))>=1e-4)//比较相邻边的长度 
            {    
                    ok = 0;
                    break;
            }
        }
        if(ok) return 1; 
    }while(next_permutation(a, a+n));
    return 0;
}


int main() {
    Point a[5];
    int n; 
    scanf("%d", &n);
    while(n--){
        for(int i = 0; i < 5; i++) {
            cin >> a[i].x >> a[i].y ;
        }
        if(jg(a, 5))cout << "Yes" << endl;
        else cout << "No"<< endl;
    } 
    
} 

BestCoder Round #62 (div.2) HDU 5563 Clarke and five-pointed star

Clarke and five-pointed star                                           Time Limit: 2000/1000 MS (Ja...

HDU 5563 Clarke and five-pointed star(判断正五边形)——BestCoder Round #62(div.1 div.2)

HDU 5563 Clarke and five-pointed star(判断正五边形)——BestCoder Round #62(div.1 div.2)

HDU_5563Clarke and five-pointed star

Clarke and five-pointed star Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K ...

【HDU5563 BestCoder Round 62 (div1)A】【计算几何 凸包】Clarke and five-pointed star 正五边形判定 正五角星判定

#include #include #include #include #include #include #include #include #include #include #include ...

hdoj5563Clarke and five-pointed star【判断五角星】

Clarke and five-pointed star Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (...

BestCoder Round #62 (div.2)-Clarke and five-pointed star(几何)

Clarke and five-pointed star    Accepts: 237    Submissions: 591  Time Limit: 2000/1000 MS (Java/Ot...

【HDU5628】Clarke and math-狄利克雷卷积+快速幂

【HDU5628】Clarke and math-狄利克雷卷积+快速幂

hdu5627 Clarke and MST (并查集)

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submissio...

HDU-5628-Clarke-and-math-狄利克雷卷积

分析:这个题目要学会数论上面的一个知识点:狄利克雷卷积。主要要知道: (f∗g)=∑d|nf(d)g()nd(f*g)=\sum_{d|n}f(d)g(){n\over{d}} f∗(g∗h)=(f∗...

hdu(5565)——Clarke and baton

这道题比赛的时候看了一下题,以为用优先队列能过,没想到常数过大,所以T了= = 题意: 现在有n个人,每个人有一个体重值w[i],然后,每次都可以使体重最大的那个人的体重值减少1,如果有多个体重值...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:hdu5563 ( Clarke and five-pointed star )
举报原因:
原因补充:

(最多只允许输入30个字)