HDOJ 5563 Clarke and five-pointed star (判断五个点组成的是否为正五角星)
来源:互联网 发布:php 上传中文文件名 编辑:程序博客网 时间:2024/05/11 03:59
Clarke and five-pointed star
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 420 Accepted Submission(s): 227
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.
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 numbersxi,yi(−109≤xi,yi≤109) , denoting the coordinate of this point.
For each test case, 5 lines follow. Each line contains 2 real numbers
Output
Two numbers are equal if and only if the difference between them is less than10−4 .
For each test case, printYes if they can compose a five-pointed star. Otherwise, print No . (If 5 points are the same, print Yes . )
For each test case, print
Sample Input
23.0000000 0.00000000.9270509 2.85316950.9270509 -2.8531695-2.4270509 1.7633557-2.4270509 -1.76335573.0000000 1.00000000.9270509 2.85316950.9270509 -2.8531695-2.4270509 1.7633557-2.4270509 -1.7633557
Sample Output
YesNoHint题意:给你5个点,求这5个点能不能连成一个正五角星思路:见每个点都连起来会发现,会组成一个五边形,而正五角星组成的是正五边形,所一说此题就转化为判断是否能组成正五边形直接枚举距离,正多边形个点之间的连线中边长一定是最短的那条边,所以我们只需要查看最短边数量是否等于5就可以判断是不是正五边形,也就能判断能不能组成正五角星。需要注意的是精度问题。可能这道题数据有点弱,窝水了过去,正式的应该是先求凸包,然后在判断,但是可能因为精度问题水了过去。。类似的题有:点击打开链接ac代码:<pre name="code" class="cpp">#include<stdio.h>#include<string.h>#include<math.h>#include<stack>#include<iostream>#include<algorithm>#define fab(a) (a)>0?(a):(-a)#define LL long long#define MAXN 1000010#define mem(x) memset(x,0,sizeof(x))#define INF 0xfffffff using namespace std;struct s{double x,y;}a[10];int v[10][10];double dis[1000];double fun(s aa,s bb){return sqrt((aa.x-bb.x)*(aa.x-bb.x)+(aa.y-bb.y)*(aa.y-bb.y));}int main(){int t,i,j;scanf("%d",&t);while(t--){for(i=0;i<5;i++)scanf("%lf%lf",&a[i].x,&a[i].y);mem(v);int k=0;double mi=1.0*INF;for(i=0;i<5;i++){for(j=i+1;j<5;j++){if(v[i][j]||v[j][i])continue;dis[k]=fun(a[i],a[j]);mi=min(mi,dis[k]);v[i][j]=1; k++;}}int cnt=0;for(i=0;i<k;i++){if(dis[i]-mi<=1e-4)//精度问题cnt++;}if(cnt==5)printf("Yes\n");elseprintf("No\n");}return 0;}
0 0
- HDOJ 5563 Clarke and five-pointed star (判断五个点组成的是否为正五角星)
- hdoj 5563 Clarke and five-pointed star 【判断五角星】
- hdoj Clarke and five-pointed star 5563 (判断能否组成五角星)
- HDOJ 5563 Clarke and five-pointed star
- HDOJ 5563 Clarke and five-pointed star(枚举)
- hdoj--5563--Clarke and five-pointed star(简单几何)
- hdoj5563Clarke and five-pointed star【判断五角星】
- HDU 5563 Clarke and five-pointed star(判断正五边形)
- HDU 5563 Clarke and five-pointed star
- HDU-5563 (Clarke and five-pointed star)
- 【HDU5563 BestCoder Round 62 (div1)A】【计算几何 凸包】Clarke and five-pointed star 正五边形判定 正五角星判定
- hdu 5563 Clarke and five-pointed star(几何)
- HDU 5563 Clarke and five-pointed star(暴力)
- hdu5563 ( Clarke and five-pointed star )
- hdu5563 Clarke and five-pointed star
- HDU 5563 Clarke and five-pointed star(判断正五边形)——BestCoder Round #62(div.1 div.2)
- BestCoder Round #62 (div.2)Clarke and five-pointed star(极角排序,判断五边形)
- BC-Clarke and five-pointed star(水)
- javascript与Jquery整理
- 卷积神经网络CNN
- QQ 添加分组 添加好友
- 数据库课程设计开发笔记(一)
- BZOJ 2115 Xor(dfs&独立回路&异或消元)
- HDOJ 5563 Clarke and five-pointed star (判断五个点组成的是否为正五角星)
- Appium Wrapper for Java
- 下一代分布式消息系统:Apache Kafka
- Apache Cordova介绍
- [HDU 1811]Rank of Tetris[拓扑排序][并查集]
- ffmpeg time_base
- 关于Socket长连接异步单工
- 【黑马程序员】C语言函数
- MongoDB小结15 - find【查询条件$ne】