hdoj--5333--Dancing Stars on Me(水题)
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
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.
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.
3
3
0 0
1 1
1 0
4
0 0
0 1
1 0
1 1
5
0 0
0 1
0 2
2 2
2 0
NO
YES
NO
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<math.h>
using namespace std;
#define MAX 100010
struct node
{
int x,y;
}point[MAX];
int map[1010][1010];
double dis[MAX];
double dist(node s1,node s2)
{
double s=sqrt((1.0*s1.x-s2.x)*(s1.x-s2.x)+(s1.y-s2.y)*(s1.y-s2.y));
return s;
}
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
int n;
double minn=10000000;
memset(dis,0,sizeof(dis));
memset(map,0,sizeof(map));
scanf("%d",&n);
for(int i=0;i<n;i++)
scanf("%d%d",&point[i].x,&point[i].y);
int cnt=0;
for(int i=0;i<n;i++)
for(int j=0;j<n;j++)
{
if(i==j) continue;
if(!map[i][j])
{
dis[cnt]=dist(point[i],point[j]);
if(minn>dis[cnt]&&dis[cnt]!=0)
minn=dis[cnt];
cnt++;
map[i][j]=1;
}
}
int ans=0;
for(int i=0;i<cnt;i++)
if(minn==dis[i]) ans++;
//printf("%d %d %d",ans,n,minn);
if(ans==2*n)
printf("YES\n");
else
printf("NO\n");
}
return 0;
}
hdoj--5333--Dancing Stars on Me(水题)的更多相关文章
- 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 ...
- HDOJ/HDU 1328 IBM Minus One(水题一个,试试手)
Problem Description You may have heard of the book '2001 - A Space Odyssey' by Arthur C. Clarke, or ...
- HDOJ(HDU) 2090 算菜价(简单水题、)
Problem Description 妈妈每天都要出去买菜,但是回来后,兜里的钱也懒得数一数,到底花了多少钱真是一笔糊涂帐.现在好了,作为好儿子(女儿)的你可以给她用程序算一下了,呵呵. Input ...
- HDOJ(HDU) 1555 How many days?(水题)
Problem Description 8600的手机每天消费1元,每消费K元就可以获赠1元,一开始8600有M元,问最多可以用多少天? Input 输入包括多个测试实例.每个测试实例包括2个整数M, ...
- HDOJ/HDU 2537 8球胜负(水题.简单的判断)
Problem Description 8球是一种台球竞赛的规则.台面上有7个红球.7个黄球以及一个黑球,当然还有一个白球.对于本题,我们使用如下的简化规则:红.黄两名选手轮流用白球击打各自颜色的球, ...
- HDOJ(HDU) 2139 Calculate the formula(水题,又一个用JavaAC不了的题目)
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) 看到这个时间,我懵逼了... 果然,J ...
- HDOJ/HDU 2561 第二小整数(水题~排序~)
Problem Description 求n个整数中倒数第二小的数. 每一个整数都独立看成一个数,比如,有三个数分别是1,1,3,那么,第二小的数就是1. Input 输入包含多组测试数据. 输入的第 ...
- HDOJ(HDU) 1562 Guess the number(水题,枚举就行)
Problem Description Happy new year to everybody! Now, I want you to guess a minimum number x betwwn ...
- HDOJ 2317. Nasty Hacks 模拟水题
Nasty Hacks Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Tota ...
- 水题 HDOJ 4727 The Number Off of FFF
题目传送门 /* 水题:判断前后的差值是否为1,b[i]记录差值,若没有找到,则是第一个出错 */ #include <cstdio> #include <iostream> ...
随机推荐
- [Debug]SpaceVim中neomake报错 Error while trying to load a compilation database
回家装上archlinux,突发奇想装个SpaceVim写题 安装配置一路可以说是没有太大问题 最后在写题时出现如下问题 Error while trying to load a compilatio ...
- 紫书 习题8-9 UVa 1613 (dfs染色+图的性质)
这道题一开始我没想什么直接开始染, 但是是for循环一个节点一个节点染, 然后就WA 后了看了https://www.cnblogs.com/jerryRey/p/4702323.html 发现原来还 ...
- CAD二次开发(02)-添加对象到模型空间
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...
- 2015 Multi-University Training Contest 1 OO’s Sequence
OO’s Sequence Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)T ...
- MarkDown写作之嵌入LaTeX和HTML
本系列文章由 @YhL_Leo 出品,转载请注明出处. 文章链接: http://blog.csdn.net/yhl_leo/article/details/49788741 Markdown 是一种 ...
- 简单搭建zookeeper集群分布式/伪分布式
分布式搭建 一.下载zookeeper安装包 自行下载:我用的是 zookeeper-3.5.4-beta.tar.gz 二.环境准备 1. 我的虚拟机自带的java是1.7的,这个版本要求java1 ...
- scratchIDE使用说明
scratchIDE使用说明
- swift学习笔记(五)构造过程
构造过程是为了使用某个类.结构体或枚举类型的实例而进行的准备过程.在构造过程中,对每一个属性进行了初始值预设和其它必要的准备和初始化工作. 与OC相比,swift的构造函数.不须要返回值.同一时候,在 ...
- 小贝_redis list类型学习
redis list类型 一.查看list类型的命令 二.list命令具体解释 一.查看list类型的命令 1.在终端数据 help @list 127.0.0.1:6379>help @li ...
- 从设计稿到demo
前言 先省略产品设计师的wireframe和mockup,为什么线框图和视觉设计稿不在叙述范围内,由于这里要做的是网页重构,从接收设计师的PSD那一刻開始: 一.接到设计稿 1.接收到PSD后.不要着 ...