Clarke and five-pointed star

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

Total Submission(s): 601    Accepted Submission(s): 322

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
 
Recommend
hujie   |   We have carefully selected several similar problems for you:  5594 5593 5592 5591 5590 
 



五角星是一个对称性极高的图形,每一个点连得线都与其他点的连线一毛一样,有木有很神奇(并没有),这道题只需要算出每一个点的所有连线,然后判断就好,水题一枚

#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
using namespace std;
struct node
{
double x,y;
}p[10010];
double dis1[10],dis2[10],dis3[10],dis4[10],dis5[10];
double d(node s1,node s2)
{
return sqrt((s1.x-s2.x)*(s1.x-s2.x)+(s1.y-s2.y)*(s1.y-s2.y));
}
int cmp(double a,double b)
{
if(a>b)
return 1;
return 0;
}
int er(double a,double b)
{
if(fabs(a-b)<1e-3)
return 1;
return 0;
}
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
int i,j;
for(i=0;i<5;i++)
scanf("%lf%lf",&p[i].x,&p[i].y);
for(j=0;j<5;j++)
dis1[j]=d(p[0],p[j]);
for(j=0;j<5;j++)
dis2[j]=d(p[1],p[j]);
for(j=0;j<5;j++)
dis3[j]=d(p[2],p[j]);
for(j=0;j<5;j++)
dis4[j]=d(p[3],p[j]);
for(j=0;j<5;j++)
dis5[j]=d(p[4],p[j]);
sort(dis1,dis1+5,cmp);
sort(dis2,dis2+5,cmp);
sort(dis3,dis3+5,cmp);
sort(dis4,dis4+5,cmp);
sort(dis5,dis5+5,cmp);
for(i=0;i<5;i++)
{
if(er(dis1[i],dis2[i])&&
er(dis2[i],dis3[i])&&
er(dis3[i],dis4[i])&&
er(dis4[i],dis5[i])&&
er(dis5[i],dis1[i]));
else break;
}
if(i==5)
printf("Yes\n");
else
printf("No\n");
}
return 0;
}

hdoj--5563--Clarke and five-pointed star(简单几何)的更多相关文章

  1. Python下opencv使用笔记(二)(简单几何图像绘制)

    简单几何图像一般包含点.直线.矩阵.圆.椭圆.多边形等等.首先认识一下opencv对像素点的定义. 图像的一个像素点有1或者3个值.对灰度图像有一个灰度值,对彩色图像有3个值组成一个像素值.他们表现出 ...

  2. Codeforces 935 简单几何求圆心 DP快速幂求与逆元

    A #include <bits/stdc++.h> #define PI acos(-1.0) #define mem(a,b) memset((a),b,sizeof(a)) #def ...

  3. hdu 5563 Clarke and five-pointed star 水题

    Clarke and five-pointed star Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/show ...

  4. HDOJ 1393 Weird Clock(明白题意就简单了)

    Problem Description A weird clock marked from 0 to 59 has only a minute hand. It won't move until a ...

  5. HDOJ 1393 Weird Clock(明确题意就简单了)

    Problem Description A weird clock marked from 0 to 59 has only a minute hand. It won't move until a ...

  6. HDOJ 1196 Lowest Bit(二进制相关的简单题)

    Problem Description Given an positive integer A (1 <= A <= 100), output the lowest bit of A. F ...

  7. ACM: FZU 2110 Star - 数学几何 - 水题

     FZU 2110  Star Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u  Pr ...

  8. 简单几何(线段相交) POJ 2653 Pick-up sticks

    题目传送门 题意:就是小时候玩的一种游戏,问有多少线段盖在最上面 分析:简单线段相交,队列维护当前最上的线段 /******************************************** ...

  9. osg for android (一) 简单几何物体的加载与显示

    1. 首先需要一个OSG for android的环境. (1).NDK 现在Eclipse 对NDK已经相当友好了,已经不需要另外cygwin的参与,具体可以参考 Android NDK开发篇(一) ...

随机推荐

  1. mysql_5.6.24_winx64 安装

    1.将zip压缩文件放在一个文件夹中 2.将路劲加入path环境变量 3.注册系统服务 在C:\windows下建立一个ini文件 1 2 3 4 5 6 7 8 9 10 11 12 [client ...

  2. POJ 3088

    已知n,求n中取k(k<=n)个数组成的m(m<=n)个的集合的排列数. 于是,可以枚举选出k个数及枚举m个集合.这个很明显是二类斯特林数.而集合有序,则乘上m! #include < ...

  3. HDU 2421

    由算术基本定理N=p1^e1*p2^e2....ps^es,可知一个素的因子个数为(e1+1)*(e2+1)*...*(es+1). 而N的一人因子必定也有n=p1^k1*p2^k2....*ps^k ...

  4. 【Android】桌面歌词悬浮效果简单实现

    在使用"网易云音乐"的时候,发现有一个显示"桌面歌词"的功能,于是就想着自己实现下.查了下资料,是用WindowManage实现的.实现过程中也出现了些问题,看 ...

  5. xcode5.1生成framework,支持arm64报错

    错误例如以下: ld: Assertion failed: (_machoSection != 0), function machoSection, file /SourceCache/ld64/ld ...

  6. 自己主动化測试程序之中的一个自己定义键盘的模拟測试程序(C语言)

    一.測试程序编写说明 我们做的终端设备上运行的是QT应用程序.使用自己定义的键盘接口.经过測试人员长时间的人机交互測试,来确认系统的功能是否满足需求. 如今须要编写一个自己主动化的測试程序,能够依照预 ...

  7. javascript 简单语法 对象属性及方法

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  8. nyoj--514--1的个数(贪心)

     1的个数 时间限制:1000 ms  |  内存限制:65535 KB 难度:3 描述 给你两个数a和b,你的任务是计算出1在a和b之间出现的次数,比如说,如果a=1024,b=1032,那么a ...

  9. sicily 1137 河床 (二分分治)

    <计算机算法设计与分析>啃书中... 有点看不进书,就来刷个水题吧,刚开始看错题了还. 注意:是所有测量点相差均不大于di而不是相邻两点... //1137.河床 #include < ...

  10. Linux下安装ipython与jupyter

    IPython从Python发展而来,更倾向于科学计算.互联网数据分析更喜欢用. 首先切换root用户: su - root pip3自动安装ipython [root@hear ~]# ipytho ...