hdu5563解题报告(计算几何)

题目链接:

http://acm.hdu.edu.cn/showproblem.php?pid=5563

题目大意:

给5个点,判断能不能组成一个正五角星

解题思路:

简单的计算几何,把一个点,同每个点的距离枚举出来(只有两种长度的边,和相邻的点的短边,和不相邻的点的长边),在排序下,挨个算误差,注意用fabs来算。、、bc是时候看到计算几何就放了,没想到是个水题

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cmath>
using namespace std;
const double eps=0.00001;
double d[100];
double dis(double x1,double y1,double x2,double y2)
{
        return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}

struct node
{
        double x;
        double y;
}p[10];

int main()
{
        int T;
        scanf("%d",&T);
        while(T--)
        {
                for(int i=1;i<=5;i++)
                scanf("%lf%lf",&p[i].x,&p[i].y);
                int cnt=1;
                for(int i=1;i<=5;++i)
                {
                   for(int j=i+1;j<=5;++j)
                        d[cnt++]=dis(p[i].x,p[i].y,p[j].x,p[j].y);
                }
                sort(d+1,d+cnt);
                int t=0;
                for(int i=2;i<cnt;i++)
                {
                        if(fabs(d[i]-d[i-1])>eps) t++;
                        if(t>1) break;
                }
                t>1?printf("No\n"):printf("Yes\n");
        }
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值