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): 223 Accepted Submission(s): 151
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.
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring> using namespace std; #define N 25 int n; struct node
{
int x, y;
}P[N]; int slove(int i, int j, int k, int q) // 判断是否为正四边形
{
if(i == j || i == k) // 不能有重点
return false;
if(i == q || j == k)
return false;
if(j == q || k == q)
return false; int w = 0, num[8];
memset(num, 0, sizeof(num)); num[w++] = (P[i].x-P[j].x)*(P[i].x-P[j].x)+(P[i].y-P[j].y)*(P[i].y-P[j].y);
num[w++] = (P[i].x-P[k].x)*(P[i].x-P[k].x)+(P[i].y-P[k].y)*(P[i].y-P[k].y);
num[w++] = (P[i].x-P[q].x)*(P[i].x-P[q].x)+(P[i].y-P[q].y)*(P[i].y-P[q].y);
num[w++] = (P[j].x-P[k].x)*(P[j].x-P[k].x)+(P[j].y-P[k].y)*(P[j].y-P[k].y);
num[w++] = (P[j].x-P[q].x)*(P[j].x-P[q].x)+(P[j].y-P[q].y)*(P[j].y-P[q].y);
num[w++] = (P[q].x-P[k].x)*(P[q].x-P[k].x)+(P[q].y-P[k].y)*(P[q].y-P[k].y); sort(num, num+w); w = unique(num, num+w) - num; if(w != 2) // 只能有两种不相同的边
return false;
return true;
} int main()
{
int t;
scanf("%d\n", &t);
while(t--)
{
scanf("%d", &n); int ans = 0; for(int i = 1; i <= n; i++)
scanf("%d%d", &P[i].x, &P[i].y);
if(n != 4)
{
printf("NO\n");
continue;
} for(int i = 1; i <= n; i++)
for(int j = i+1; j <= n; j++)
for(int k = j+1; k <= n; k++)
for(int q = k+1; q <= n; q++)
if(slove(i, j, k, q))
ans++;
if(ans != 0)
printf("YES\n");
else
printf("NO\n");
}
return 0;
}
Dancing Stars on Me的更多相关文章
- 2015ACM/ICPC亚洲区长春站 G hdu 5533 Dancing Stars on Me
Dancing Stars on Me Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Ot ...
- 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 ...
- hdu 5533 Dancing Stars on Me
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5533 Dancing Stars on Me Time Limit: 2000/1000 MS (Ja ...
- Dancing Stars on Me(判断正多边形)
Dancing Stars on Me Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Ot ...
- HDU 5533/ 2015长春区域 G.Dancing Stars on Me 暴力
Dancing Stars on Me Problem Description The sky was brushed clean by the wind and the stars were col ...
- hdu 5533 Dancing Stars on Me(数学,水)
Problem Description The sky was brushed clean by the wind and the stars were cold in a black sky. Wh ...
- 【2015 ICPC亚洲区域赛长春站 G】Dancing Stars on Me(几何+暴力)
Problem Description The sky was brushed clean by the wind and the stars were cold in a black sky. Wh ...
- Dancing Stars on Me---hdu5533(判断是否为正多边形)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5533 题意:平面图中 有n个点给你每个点的坐标,判断是否能通过某种连线使得这些点所组成的n边形为 正n ...
- 【HDOJ5533】Dancing Stars on Me(计算几何)
题意:给定二维平面上的n个整点,问它们是否都在正n边形的定点上 n<=100,abs(x[i]),abs(y[i])<=1e4 思路:队友做的,抱大腿 可以发现只有n=4时顶点有可能都是整 ...
随机推荐
- 九、Zabbix-触发器
1.触发器是用来触发报警,或这其他动作的机制,它需要依赖监控项,以监控项为基础创建 3.创建触发器 (1)配置—>模板—>需要调整的模板—>触发器 (2)编辑触发器
- 初涉Java
一.学习内容总结 1.程序入口 但如果类的定义使用了public class声明,那么文件名必须与类名保持一致,使用了class定义的类,文件名称可以和类名称不同. 2.输出语句 3.print与pr ...
- [转帖]JVM内存结构 VS Java内存模型 VS Java对象模型
JVM内存结构 VS Java内存模型 VS Java对象模型 https://www.hollischuang.com/archives/2509 Java作为一种面向对象的,跨平台语言,其对象.内 ...
- python学习第五十三天configParser模块的使用
configParser 模块用于生成和修改常见配置文档,python 3.x为configParser,配置软件的常见配置格式 模块的用法 import configparser config=co ...
- 连连看(简单搜索)bfs
连连看Time Limit: 20000/10000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submis ...
- 【 React -- 2/100 】使用React实现评论功能
React| 组件化 | 递归 | 生成唯一ID 需要探究一下 .find() 和 findIndex() 的区别 import React from 'react' import './commen ...
- Servlet实现Cookie自动登录,并显示保存的用户信息
转自:https://blog.csdn.net/qq_29612963/article/details/51100565
- 看CLRS 对B树的浅显理解
定义及特点: 每个结点有n个关键字和n+1个指向子结点的指针,即有n+1个孩子结点. n个关键字按非递减的顺序存储. 最小度数t>=2,除了根结点的所有内部结点(非叶结点)的孩子数>=t且 ...
- STM32 总线
AHB,是Advanced High performance Bus的缩写,译作高级高性能总线,这是一种“系统总线”.AHB主要用于高性能模块(如CPU.DMA和DSP等)之间的连接.AHB 系统由主 ...
- moc_XXXX.o:(.data.rel.ro._ZTI12CalculatorUI[_ZTI12CalculatorUI]+0x10): undefined reference to `typeinfo for QWidget' collect2: error: ld returned 1 exit status make: *** [Makefile:144: myCalculator]
main.cpp:(.text.startup+0x22): undefined reference to `QApplication::QApplication(int&, char**, ...