题意: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. 5.3:从bean的实例中获取对象

    5.3  从bean的实例中获取对象 在getBean方法中,getObjectForBeanInstance是个高频率使用的方法,无论是从缓存中获得bean还是根据不同的scope策略加载bean. ...

  2. 你不需要jQuery(五)

    什么不用jQuery?因为它让你的网站体积变得臃肿.你的网站并不真的需要jQuery,不需要它带来的额外体积.带宽和加载时间. 用原生JavaScript简单实现jQuery提供的功能和方法 查找.选 ...

  3. 【线段树/数学/扩展欧几里得】 Bzoj 3913:奇数国

    Description 在一片美丽的大陆上有100000个国家,记为1到100000.这里经济发达,有数不尽的账房,并且每个国家有一个银行.某大公司的领袖在这100000个银行开户时都存了3大洋,他惜 ...

  4. Android Activity交互及App交互

    Android交互--------->Intent Activity之间----->Explicit Intent App之间--------->Implicit Intent

  5. ECSHOP报错误Deprecated: preg_replace(): The /e modifier is depr

    http://www.ecshoptemplate.com/article-1850.html

  6. JAVA面试题:equals()方法和== 区别

    http://bbs.csdn.net/topics/390000725 总结: equals在没重写之前和==一样,重写之后,equals只要内容一样即为true equals跟==一般情况下是等价 ...

  7. Google-Gson使用

    转自:http://my.oschina.net/itblog/blog/204120 这几天,因为项目的需要,接触了Google的Gson库,发现这个东西很好用,遂记下简单的笔记,供以后参考.至于G ...

  8. Android面试宝典(转)

    Java知识点包括:接口与抽象的使用及区别,多线程,socket基础,集合类,也有个别公司考察定义,很无语. C/C++知识点包括:指针的移动,排序算法,链表,有时还会有二叉树的遍历或图的遍历. 1. ...

  9. Java List详解

    就是一种集合对象,将所有的对象集中到一起存储. list里面可以放java对象,可以直接放值. List list = new ArrayList(); list.add("AAA" ...

  10. 8款替代Dreamweaver的开源网页开发工具

    Adobe Dreamweaver虽然非常好用,但它并不是唯一一个能够设计.开发.发布精彩网站的Web开发集成环境.我们的开源世界里有很多非常棒的可以完全替代Dreamweaver的各种功能的优秀We ...