题意:n个顶点组成的多边形能否形成正多边形?

 #include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <queue>
#include <map>
#include <vector>
using namespace std;
const int maxn=;
const int maxnode=;
typedef long long LL;
struct Point
{
int x,y;
Point (int x=,int y=):x(x),y(y) {} } p[maxn];
typedef Point Vector;
Vector operator+(Vector A,Vector B)
{
return Vector(A.x+B.x,A.y+B.y);
} Vector operator-(Point A,Point B)
{
return Vector(A.x-B.x,A.y-B.y);
}
Vector operator*(Vector A,int p)
{
return Vector(A.x*p,A.y*p);
} Vector operator /(Vector A,int p)
{
return Vector(A.x/p,A.y/p);
} bool operator <(const Point&a,const Point &b)
{
return a.x<b.x||(a.x==b.x&&a.y<b.y);
} int Cross(Vector A,Vector B)
{
return A.x*B.y-A.y*B.x;
} int ConvexHull(Point *p,int n,Point *ch)
{
sort(p,p+n);
int m=;
for(int i=; i<n; i++)
{
while(m>&&Cross(ch[m-]-ch[m-],p[i]-ch[m-])<=)
m--;
ch[m++]=p[i];
}
int k=m;
for(int i=n-; i>=; i--)
{
while(m>k&&Cross(ch[m-]-ch[m-],p[i]-ch[m-])<=)m--;
ch[m++]=p[i];
}
if(n>)
m--;
return m;
}
int n;
Point ans[maxn];
LL dis(LL X1,LL Y1,LL X2,LL Y2)
{
return (X1-X2)*(X1-X2)+(Y1-Y2)*(Y1-Y2);
}
int main()
{
freopen("in.txt","r",stdin);
int t ;
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
for(int i=; i<n; i++)
scanf("%d%d",&p[i].x,&p[i].y);
int m=ConvexHull(p,n,ans);
if(m!=n)
{
printf("NO\n");
continue;
}
bool flag=true;
LL len=dis(ans[].x,ans[].y,ans[m-].x,ans[m-].y); for(int i=; i<m; i++)
{
if(len!=dis(ans[i].x,ans[i].y,ans[i-].x,ans[i-].y))
{
flag=false;
break;
}
}
if(flag)printf("YES\n");
else printf("NO\n"); }
return ;
}

2015长春 HDU 5531 Rebuild的更多相关文章

  1. HDU 5531 Rebuild (2015长春现场赛,计算几何+三分法)

    Rebuild Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total S ...

  2. HDU 5531 Rebuild

    2015 ACM/ICPC 长春现场赛 E题 三分. 如果节点个数是奇数,那么直接列方程可以求解,因为,如果第一个圆半径变大,必然导致最后一个圆的半径变大, 所以,节点是奇数的时候,要么无解,要么只有 ...

  3. 2015ACM/ICPC亚洲区长春站 E hdu 5531 Rebuild

    Rebuild Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total S ...

  4. 2015长春 HDU 5534 Partial Tree

    题意:有n个结点,n-1条边,现在要把这n个结点连成一棵树,给定了f(i),表示度为i的结点的价值是f(i).现在问如何连能够使得Σf(i)的值最大. 思路:每个点至少一个度,所以可分配的度数为n-2 ...

  5. hdu 5441 Travel (2015长春网赛)

    http://acm.hdu.edu.cn/showproblem.php?pid=5441 题目大意是给一个n个城市(点)m条路线(边)的双向的路线图,每条路线有时间值(带权图),然后q个询问,每个 ...

  6. Hdu 5439 Aggregated Counting (2015长春网络赛 ACM/ICPC Asia Regional Changchun Online 找规律)

    题目链接: Hdu 5439 Aggregated Counting 题目描述: 刚开始给一个1,序列a是由a[i]个i组成,最后1就变成了1,2,2,3,3,4,4,4,5,5,5.......,最 ...

  7. Hdu 5445 Food Problem (2015长春网络赛 ACM/ICPC Asia Regional Changchun Online)

    题目链接: Hdu  5445 Food Problem 题目描述: 有n种甜点,每种都有三个属性(能量,空间,数目),有m辆卡车,每种都有是三个属性(空间,花费,数目).问至少运输p能量的甜点,花费 ...

  8. HDU 5534/ 2015长春区域H.Partial Tree DP

    Partial Tree Problem Description In mathematics, and more specifically in graph theory, a tree is an ...

  9. Travel(HDU 5441 2015长春区域赛 带权并查集)

    Travel Time Limit: 1500/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Su ...

随机推荐

  1. c++实现文本中英文单词和汉字字符的统计

    源代码下载:http://download.csdn.net/detail/nuptboyzhb/4987141 1.统计文本中汉字的频数,为后续的文本分类做基础.对于汉字的统计,需要判断读取的是否为 ...

  2. ubuntu 和 win7 远程登陆 + vnc登陆

    ubuntu 和 win7 远程登陆: 第一种(通过win7自带的远程桌面来连接ubuntu) 1. windows7配置 我的电脑->属性->远程设置.-----允许远程连接 2. ub ...

  3. linux查找某个文件中单词出现的次数

    文件名称:list 查找单词名称:test 操作命令: (1)more list | grep -o test | wc -l (2)cat list | grep -o test | wc -l ( ...

  4. 【前端学习】【jQuery选择器】

    jQuery选择器     jQuery选择器 本文内容引自于单东林<锋利的jQuery>,未经原作者准许,禁止以商业目的转载发布! 选择器是jQuery的根基,在jQuery中,对事件处 ...

  5. Some projects cannot be imported because they already exist in the workspace

    原文地址: Some projects cannot be imported because they already exist in the workspace - 浅尝辄止的博客 - 博客频道 ...

  6. Git教程之使用GitHub

    我们一直用GitHub作为免费的远程仓库,如果是个人的开源项目,放到GitHub上是完全没有问题的.其实GitHub还是一个开源协作社区,通过GitHub,既可以让别人参与你的开源项目,也可以参与别人 ...

  7. POJ2531——Network Saboteur(随机化算法水一发)

    Network Saboteur DescriptionA university network is composed of N computers. System administrators g ...

  8. POJ2586——Y2K Accounting Bug

    Y2K Accounting Bug   Description Accounting for Computer Machinists (ACM) has sufferred from the Y2K ...

  9. [原]Unity3D深入浅出 - 光源组件(Light)

    Unity中提供了四种光源: Directional light: 方向光,类似太阳的日照效果. Point light: 点光源,类似蜡烛. Spotlight: 聚光灯,类似手电筒. Area L ...

  10. bzoj1385: [Baltic2000]Division expression

    欧几里得算法.可以发现规律,a[2]作为分母,其他作为分子,必定是最好的选择.判断是否为整数即可. #include<cstdio> #include<cstring> #in ...