【HDOJ5533】Dancing Stars on Me(计算几何)
题意:给定二维平面上的n个整点,问它们是否都在正n边形的定点上
n<=100,abs(x[i]),abs(y[i])<=1e4
思路:队友做的,抱大腿
可以发现只有n=4时顶点有可能都是整点,判一下对角线与边长就行
我与队友互演,WA了5发……
#include<bits/stdc++.h>
using namespace std;
#define LL long long
const int maxn=1e3+;
struct node{
int x,y;
}a[maxn];
int dis(int i,int j)
{
return (a[i].x-a[j].x)*(a[i].x-a[j].x)+(a[i].y-a[j].y)*(a[i].y-a[j].y);
}
int main()
{
int T;
scanf("%d",&T);
while(T--)
{
int n;
scanf("%d",&n);
for(int i=;i<=n;i++)
{
scanf("%d%d",&a[i].x,&a[i].y);
}
if(n!=)
{
printf("NO\n");
}
else
{
int g=;
int d=;
for(int i=;i<=;i++)
{
if(dis(,i)>d)
{
g=i;
d=dis(,i);
}
}
if(g!=)
swap(a[],a[g]);
int f=;
if(dis(,)==dis(,)&&dis(,)==dis(,)&&dis(,)==dis(,)&&dis(,)==dis(,))
f=;
if(f)
printf("YES\n");
else
printf("NO\n");
}
} }
【HDOJ5533】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 ...
- 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( 有趣的计算几何 )
链接:传送门 题意:给出 n 个点,判断能不能构成一个正 n 边形,这 n 个点坐标是整数 思路:这道题关键就在与这 n 个点坐标是正整数!!!可以简单的分析,如果 n != 4,那一定就不能构成正 ...
- 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 ...
- HDU 1589 Stars Couple(计算几何求二维平面的最近点对和最远点对)
Time Limit: 1000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission( ...
随机推荐
- 32-3题:LeetCode103. Binary Tree Zigzag Level Order Traversal锯齿形层次遍历/之字形打印二叉树
题目 给定一个二叉树,返回其节点值的锯齿形层次遍历.(即先从左往右,再从右往左进行下一层遍历,以此类推,层与层之间交替进行). 例如: 给定二叉树 [3,9,20,null,null,15,7], 3 ...
- java 获取request中的请求参数
1.get 和 post请求方式 (1)request.getParameterNames(); 获取所有参数key后.遍历request.getParameter(key)获取value (2)re ...
- Centos7之Nginx
1.安装 下载RPM: wget http://nginx.org/download/nginx-1.16.0.tar.gz 解压:tar -zxf nginx-1.16.0.tar.gz 安装: c ...
- LeetCode949-给定数字能组成的最大时间
问题: 给定一个由 4 位数字组成的数组,返回可以设置的符合 24 小时制的最大时间. 最小的 24 小时制时间是 00:00,而最大的是 23:59.从 00:00 (午夜)开始算起,过得越久,时间 ...
- Python_循环判断表达式
一.if判断 计算机之所以能做很多自动化的任务,因为它可以自己做条件判断. if判断结构: if 条件: 动作 elif 条件: 动作 else: 动作 if判断年龄: age_of_princal ...
- Python导入模块方法
import module_name 导入整个模块 from module_name import function_name 导入特定函数 from module_name import funct ...
- 基于django的个人博客网站建立(二)
基于django的个人博客网站建立(二) 前言 网站效果可点击这里访问 今天主要完成后台管理员登录的状态以及关于文章在后台的处理 具体内容 首先接上一次内容,昨天只是完成了一个登录的跳转,其他信息并没 ...
- python3中文件的读与写
Python open() 函数用于打开一个文件,并返回文件对象,在对文件进行处理过程都需要使用到这个函数,如果该文件无法被打开,会抛出错误 完整语法:open(file, mode='r', buf ...
- shell脚本中的交互式输入自动化
shell中有时我们需要交互,但是呢我们又不想每次从stdin输入,想让其自动化,这时我们就要使shell交互输入自动化了. 1 利用重定向 重定向的方法应该是最简单的 例: 以下的te ...
- Codeforces Round #464 (Div. 2) D. Love Rescue
D. Love Rescue time limit per test2 seconds memory limit per test256 megabytes Problem Description V ...