Dancing Stars on Me

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

Total Submission(s): 582    Accepted Submission(s): 308

Problem Description
The sky was brushed clean by the wind and the stars were cold in a black sky. What a wonderful night. You observed that, sometimes the stars can form a regular polygon in the sky if we connect them properly. You want to record these
moments by your smart camera. Of course, you cannot stay awake all night for capturing. So you decide to write a program running on the smart camera to check whether the stars can form a regular polygon and capture these moments automatically.



Formally, a regular polygon is a convex polygon whose angles are all equal and all its sides have the same length. The area of a regular polygon must be nonzero. We say the stars can form a regular polygon if they are exactly the vertices of some regular polygon.
To simplify the problem, we project the sky to a two-dimensional plane here, and you just need to check whether the stars can form a regular polygon in this plane.
 
Input
The first line contains a integer
T
indicating the total number of test cases. Each test case begins with an integer
n,
denoting the number of stars in the sky. Following
n
lines, each contains 2
integers xi,yi,
describe the coordinates of n
stars.



1≤T≤300

3≤n≤100

−10000≤xi,yi≤10000

All coordinates are distinct.
 
Output
For each test case, please output "`YES`" if the stars can form a regular polygon. Otherwise, output "`NO`" (both without quotes).
 
Sample Input
  1. 3
  2. 3
  3. 0 0
  4. 1 1
  5. 1 0
  6. 4
  7. 0 0
  8. 0 1
  9. 1 0
  10. 1 1
  11. 5
  12. 0 0
  13. 0 1
  14. 0 2
  15. 2 2
  16. 2 0
 
Sample Output
  1. NO
  2. YES
  3. NO

  1. #include<stdio.h>
  2. #include<string.h>
  3. #include<algorithm>
  4. #include<math.h>
  5. using namespace std;
  6. #define MAX 100010
  7. struct node
  8. {
  9. int x,y;
  10. }point[MAX];
  11. int map[1010][1010];
  12. double dis[MAX];
  13. double dist(node s1,node s2)
  14. {
  15. double s=sqrt((1.0*s1.x-s2.x)*(s1.x-s2.x)+(s1.y-s2.y)*(s1.y-s2.y));
  16. return s;
  17. }
  18. int main()
  19. {
  20. int t;
  21. scanf("%d",&t);
  22. while(t--)
  23. {
  24. int n;
  25. double minn=10000000;
  26. memset(dis,0,sizeof(dis));
  27. memset(map,0,sizeof(map));
  28. scanf("%d",&n);
  29. for(int i=0;i<n;i++)
  30. scanf("%d%d",&point[i].x,&point[i].y);
  31. int cnt=0;
  32. for(int i=0;i<n;i++)
  33. for(int j=0;j<n;j++)
  34. {
  35. if(i==j) continue;
  36. if(!map[i][j])
  37. {
  38. dis[cnt]=dist(point[i],point[j]);
  39. if(minn>dis[cnt]&&dis[cnt]!=0)
  40. minn=dis[cnt];
  41. cnt++;
  42. map[i][j]=1;
  43. }
  44. }
  45. int ans=0;
  46. for(int i=0;i<cnt;i++)
  47. if(minn==dis[i]) ans++;
  48. //printf("%d %d %d",ans,n,minn);
  49. if(ans==2*n)
  50. printf("YES\n");
  51. else
  52. printf("NO\n");
  53. }
  54. return 0;
  55. }

hdoj--5333--Dancing Stars on Me(水题)的更多相关文章

  1. hdu 5533 Dancing Stars on Me 水题

    Dancing Stars on Me Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.p ...

  2. HDOJ/HDU 1328 IBM Minus One(水题一个,试试手)

    Problem Description You may have heard of the book '2001 - A Space Odyssey' by Arthur C. Clarke, or ...

  3. HDOJ(HDU) 2090 算菜价(简单水题、)

    Problem Description 妈妈每天都要出去买菜,但是回来后,兜里的钱也懒得数一数,到底花了多少钱真是一笔糊涂帐.现在好了,作为好儿子(女儿)的你可以给她用程序算一下了,呵呵. Input ...

  4. HDOJ(HDU) 1555 How many days?(水题)

    Problem Description 8600的手机每天消费1元,每消费K元就可以获赠1元,一开始8600有M元,问最多可以用多少天? Input 输入包括多个测试实例.每个测试实例包括2个整数M, ...

  5. HDOJ/HDU 2537 8球胜负(水题.简单的判断)

    Problem Description 8球是一种台球竞赛的规则.台面上有7个红球.7个黄球以及一个黑球,当然还有一个白球.对于本题,我们使用如下的简化规则:红.黄两名选手轮流用白球击打各自颜色的球, ...

  6. HDOJ(HDU) 2139 Calculate the formula(水题,又一个用JavaAC不了的题目)

    Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) 看到这个时间,我懵逼了... 果然,J ...

  7. HDOJ/HDU 2561 第二小整数(水题~排序~)

    Problem Description 求n个整数中倒数第二小的数. 每一个整数都独立看成一个数,比如,有三个数分别是1,1,3,那么,第二小的数就是1. Input 输入包含多组测试数据. 输入的第 ...

  8. HDOJ(HDU) 1562 Guess the number(水题,枚举就行)

    Problem Description Happy new year to everybody! Now, I want you to guess a minimum number x betwwn ...

  9. HDOJ 2317. Nasty Hacks 模拟水题

    Nasty Hacks Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Tota ...

  10. 水题 HDOJ 4727 The Number Off of FFF

    题目传送门 /* 水题:判断前后的差值是否为1,b[i]记录差值,若没有找到,则是第一个出错 */ #include <cstdio> #include <iostream> ...

随机推荐

  1. Oralce 视图 view

    Oracle视图 Oracle的数据库对象分为五种:表,视图,序列,索引和同义词. 视图是基于一个表或多个表或视图的逻辑表,本身不包含数据,通过它可以对表里面的数据进行查询和修改.视图基于的表称为基表 ...

  2. sz xshell

    yum install lrzsz -y

  3. linux指令--用户和工作组管理

    >>前言    Linux是一个多用户.多任务的操作系统,Linux系统的初衷之一就是满足多用户同时工作的需求,因此,linux需要具备很好的安全性,需要对用户进行管理,用户又分几种,管理 ...

  4. ZOJ 3369 Saving Princess

    Saving Princess Time Limit: 1000ms Memory Limit: 32768KB This problem will be judged on ZJU. Origina ...

  5. unity3D常见问题

    总结自己在学习中遇到的问题. 记录问题,帮助他人,有什么不正确的地方欢迎指正 没有发生碰撞 两个物体(Plane和Cube)都加入了collider,当中一个加入了rigidbody,应该会产生碰撞, ...

  6. HDU 4704 Sum Fermat定律

    Problem Description   Sample Input 2   Sample Output 2 Hint 1. For N = 2, S(1) = S(2) = 1. 2. The in ...

  7. HDU 4081 Qin Shi Huang&#39;s National Road System 最小生成树

    点击打开链接题目链接 Qin Shi Huang's National Road System Time Limit: 2000/1000 MS (Java/Others)    Memory Lim ...

  8. R语言适配问题集锦

    画图时的中文乱码问题 我这是Mac Yousemite 10.10.5,在两个地方遇到了中文乱码 1.使用wordcloud包绘制中文标签云时. library(wordcloud) mydata & ...

  9. git ---- 产生冲突的场景 和解决办法

    1.git冲突的场景 情景一:多个分支代码合并到一个分支时: 情景二:多个分支向同一个远端分支推送代码时: 实际上,push操作即是将本地代码merge到远端库分支上. 关于push和pull其实就分 ...

  10. BZOJ 3524主席树裸题 (雾)

    思路: 按权值建一棵主席树 (但是这好像不是正解 空间复杂度是不对的--.) //By SiriusRen #include <cstdio> #include <cstring&g ...