hdoj Clarke and five-pointed star 5563 (判断能否组成五角星)
2015-11-25 22:19
357 查看
Clarke and five-pointed star
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 566 Accepted Submission(s): 298
[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]
#include<stdio.h> #include<string.h> #include<math.h> #include<algorithm> #define INF 0x3f3f3f3f using namespace std; double b[3100]; int map[310][310]; struct zz { double x; double y; }a[310]; 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); int k=0; double mm=1.0*INF; memset(map,0,sizeof(map)); for(i=0;i<5;i++) { for(j=i+1;j<5;j++) { if(map[i][j]||map[j][i])//消除重边 continue; b[k]=(a[i].x-a[j].x)*(a[i].x-a[j].x)+(a[i].y-a[j].y)*(a[i].y-a[j].y); mm=min(mm,b[k]); k++; map[i][j]=1; } } int num=0; for(i=0;i<k;i++) if(b[i]-mm<=1e-4) num++; if(num==5) printf("Yes\n"); else printf("No\n"); } return 0; }
相关文章推荐
- oracle支持的事物
- 1、MySQL单双实例安装
- Git详解一
- 用Windows API实现Wave录音程序和WaveRecorder类
- lamp+nginx代理+discuz+wordpress+phpmyadmin
- iOS 中图片循环动画
- 畅谈Javascript设计模式(序)
- xmanager centos6
- 对C++中避免异常发生中的资源泄漏的认识
- 2、vector的实现
- Using Linux epoll with Python
- hdu4126树形dp + 错误分析
- Android-Toast和Notification
- Activity的启动Flag
- Android自定义控件开发系列(三)——仿支付宝六位支付密码输入页面
- jdk与jre的区别
- lightoj 1198Karate Competition
- 莫往Applicaotion存缓存/app被系统回收之后再打开发生了什么
- Oracle之自定义函数
- wustoj 1187 今年暑假不AC