hdoj--5563--Clarke and five-pointed star(简单几何)
2015-12-12 14:13
459 查看
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
[align=left]Problem Description[/align]
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.
[align=left]Input[/align]
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.
[align=left]Output[/align]
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.
)
[align=left]Sample Input[/align]
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
[align=left]Sample Output[/align]
Yes No Hint
[align=left]Source[/align]
BestCoder Round #62 (div.2)
[align=left]Recommend[/align]
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; }
相关文章推荐
- wait() 与 sleep
- zzulioj 1827: 石锅全拌 (线段树求区间和)
- jqurey.fullpage.js解读
- git 自动补全
- ubuntu中wine的安装位置
- House Robber I & II | LeetCode
- ucenter单点登录
- android Installation error: INSTALL_FAILED_DUPLICATE_PERMISSION 解决方案
- Windows程序设计--设置滚动条详解二
- redis入门笔记(2)
- 二叉搜索 方法
- ObjectOutputStream 追加写入读取错误
- 第三章-循环语句
- redis入门笔记(1)
- 还是畅通工程(1233 并查集+kruskal)
- glusterfs repo
- js实现堆排序
- mysql一次安装问题
- 第十五周项目二 (2)用哈希法组织关键字
- UML——活动图、状态图