HDU 5533Dancing Stars on Me 基础几何
Problem Description
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.
1≤T≤300
3≤n≤100
−10000≤xi,yi≤10000
All coordinates are distinct.
题意:问你是不是正多边形。
思路:瞎暴力XD。直接存所有点间连线的边长,偶数多边形长度一样的肯定有n/2个和n个,奇数多边形相同边长的一定是n啦。
/** @Date : 2016-12-10-22.55
* @Author : Lweleth (SoungEarlf@gmail.com)
* @Link : https://github.com/
* @Version :
*/
//#include <stdio.h>
//#include <iostream>
//#include <string.h>
//#include <algorithm>
//#include <utility>
//#include <vector>
//#include <map>
//#include <set>
//#include <string>
//#include <stack>
//#include <queue>
#include<bits/stdc++.h>
#define LL long long
#define PII pair<int ,int>
#define MP(x, y) make_pair((x),(y))
#define fi first
#define se second
#define PB(x) push_back((x))
#define MMG(x) memset((x), -1,sizeof(x))
#define MMF(x) memset((x),0,sizeof(x))
#define MMI(x) memset((x), INF, sizeof(x))
using namespace std; const int INF = 0x3f3f3f3f;
const int N = 1e5+20;
const double eps = 1e-8; struct yuu
{
double x; double y;
bool operator == (const yuu &a) const
{
return (a.x == this->x) && (a.y == this->y);
}
}s[110], t[N]; int cmp(yuu a, yuu b)
{
if(a.x != b.x)
return a.x > b.x;
return a.y > b.y;
}
map<double , int>q;
int main()
{
int T;
scanf("%d", &T);
while(T--)
{
int n;
scanf("%d", &n);
q.clear();
for(int i = 1; i <= n; i++)
scanf("%lf%lf", &s[i].x, &s[i].y); int cnt = 0;
for(int i = 1; i <= n; i++)
{
for(int j = i + 1; j <= n; j++)
{
double mx = fabs(s[i].x - s[j].x);
double my = fabs(s[i].y - s[j].y);
double len = mx * mx + my * my;
q[len]++;
}
}
int flag = 0;
for(auto i = q.begin(); i != q.end(); i++)
{
if(n & 1 && i->second != n)
{
flag = 1;
break;
}
else if(n % 2 == 0)
{
if(i->second != n / 2 && i->second != n)
{
flag = 1;
break;
}
}
}
if(flag)
printf("NO\n");
else printf("YES\n"); }
return 0;
}
HDU 5533Dancing Stars on Me 基础几何的更多相关文章
- hdu 1541 Stars
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1541 思路:要求求出不同等级的星星的个数,开始怎么也想不到用树状数组,看完某些大神的博客之后才用树状数 ...
- hdu 1577 WisKey的眼神 (数学几何)
WisKey的眼神 Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total S ...
- POJ 2352 Stars(HDU 1541 Stars)
Stars Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 41521 Accepted: 18100 Descripti ...
- hdu 2642 Stars
Problem Description Yifenfei is a romantic guy and he likes to count the stars in the sky. To make t ...
- POJ 3831 & HDU 3264 Open-air shopping malls(几何)
题目链接: POJ:id=3831" target="_blank">http://poj.org/problem?id=3831 HDU:http://acm.h ...
- HDU 1541 Stars (树状数组)
Problem Description Astronomers often examine star maps where stars are represented by points on a p ...
- POJ 2352 && HDU 1541 Stars (树状数组)
一開始想,总感觉是DP,但是最后什么都没想到.还暴力的交了一发. 然后開始写线段树,结果超时.感觉自己线段树的写法有问题.改天再写.先把树状数组的写法贴出来吧. ~~~~~~~~~~~~~~~~~~~ ...
- hdu 5126 stars (四维偏序,离线,CDQ套CDQ套树状数组)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5126 思路:支持离线,那么我们可以用两次CDQ分治使四维降为二维,降成二维后排个序用树状数组维护下就好 ...
- 2017中国大学生程序设计竞赛 - 网络选拔赛 HDU 6154 CaoHaha's staff(几何找规律)
Problem Description "You shall not pass!"After shouted out that,the Force Staff appered in ...
随机推荐
- nodejs笔记--Events篇(二)
常用事件 /* 调用events模块,获取events.EventEmitter对象 */ var EventEmitter = require('events').EventEmitter; var ...
- C与C++,面向过程与面向对象
C与C++在电梯处理上的不同 (注:个人理解) 对比区别: C语言程序制定具体流程,按流程逐步进行. C++程序将过程结构化,需要使用时利用接口访问与调用不同功能的类结构结构. 电梯类代码 电梯类定义 ...
- java — 设计模式
设计模式(Design pattern)是一套被反复使用.多数人知晓的.经过分类编目的.代码设计经验的总结.使用设计模式是为了可重用代码.让代码更容易被他人理解.保证代码可靠性. 一.设计模式的分类 ...
- TCP系列19—重传—9、thin stream下的重传
一.介绍 当TCP连续大量的发送数据的时候,当出现丢包的时候可以有足够的dup ACK来触发快速重传.但是internet上还有大量的交互式服务,这类服务一般都是由小包组成,而且一次操作中需要传输的数 ...
- 3dContactPointAnnotationTool开发日志(十一)
把image也做成panel的形式了,并且放进了scrollView里,真实地显示出图像: 其它两个scrollView的content也做成自适应大小了,就是添加一项content的heig ...
- 第一章 持续集成jenkins工具使用之部署
1.1 硬件要求 内存:至少512MB 磁盘空间:10G JDK8 最好同时安装jre 从官网https://jenkins.io/download/下载最新的war包(Generic Java Pa ...
- springMVC视图有哪些?-009
html,json,pdf等. springMVC 使用ViewResolver来根据controller中返回的view名关联到具体的view对象. 使用view对象渲染返回值以生成最终的视图,比如 ...
- 显示系统中所有的socket信息
netstat -aon /proc/net/tcp /proc/net/udp /proc/net/unix 相关的代码是:tcp4_seq_show(struct seq_file *file, ...
- stm32f4xx标准外设固件库
STM32F4的相关资料:http://www.stmcu.org/document/list/index/category-523 一.标准固件库简介 本文下载的是STM32F4xx_DSP_Std ...
- httpservlet在创建实例对象时候默认调用有参数的init方法 destroy()方法 service方法, 父类的init方法给子类实例一个config对象