Description

On a two-dimensional plane, give you n integer points. Your task is to figure out how many different regular polygon these points can make.
 

Input

The input file consists of several test cases. Each case the first line is a numbers N (N <= 500). The next N lines ,each line contain two number Xi and Yi(-100 <= xi,yi <= 100), means the points’ position.(the data assures no two points share the same position.)
 

Output

For each case, output a number means how many different regular polygon these points can make.
 
Sample

Sample Input

Sample Output

题意:

  给定n个整数点,问能组成多少正n边形。

思路:

  因为给出的是整数点,所以只可能是正方形

  可以枚举正方形的对角线,因为有两条对角线,最后答案要/2

  也可以枚举正方形的边,因为有四条边,答案要/4

代码:

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm> #define MAX 2000 using namespace std; struct node
{
int x,y;
} p[MAX]; int vis[MAX][MAX]; int solve(int node1,int node2)
{
int x = p[node1].x - p[node2].x;
int y = p[node1].y - p[node2].y;
int ans=;
if(p[node1].x-y>= && p[node1].y+x>= && p[node2].x-y>= && p[node2].y+x>= )//判断成正方形的条件
if(vis[p[node1].x-y][p[node1].y+x] && vis[p[node2].x-y][p[node2].y+x])//判断两个点是否存在
ans++;
if(p[node1].x+y>= && p[node1].y-x>= && p[node2].x+y>= && p[node2].y-x>= )
if( vis[p[node1].x+y][p[node1].y-x] && vis[p[node2].x+y][p[node2].y-x])
ans++;
return ans;
} int main()
{
int n,x,y;
while(scanf("%d",&n)!=EOF)
{
int ans = ;
memset(vis,,sizeof(vis));
//vis数组用来查看是否存在,结构体p用来存所有的点
for(int i=; i<n; i++)
{
scanf("%d%d",&x,&y);
vis[x+][y+] = ;//注意+200是为了将负数化为正数
p[i].x = x+;
p[i].y = y+;
}
//枚举所有的点
for(int i=; i<n; i++)
{
for(int j=i+; j<n; j++)
{
ans += solve(i,j);
}
} ans /= ;//因为枚举的是边长,所以最后除以4 printf("%d\n",ans);
}
return ;
}

HDU6055 Regular polygon(计算几何)的更多相关文章

  1. hdu6055 Regular polygon 脑洞几何 给定n个坐标(x,y)。x,y都是整数,求有多少个正多边形。因为点都是整数点,所以只可能是正四边形。

    /** 题目:hdu6055 Regular polygon 链接:http://acm.hdu.edu.cn/showproblem.php?pid=6055 题意:给定n个坐标(x,y).x,y都 ...

  2. hdu 4033 Regular Polygon 计算几何 二分+余弦定理

    题目链接 给一个n个顶点的正多边形, 给出多边形内部一个点到n个顶点的距离, 让你求出这个多边形的边长. 二分边长, 然后用余弦定理求出给出的相邻的两个边之间的夹角, 看所有的加起来是不是2Pi. # ...

  3. HDU 6055 17多校 Regular polygon(计算几何)

    Problem Description On a two-dimensional plane, give you n integer points. Your task is to figure ou ...

  4. HDU 6055 Regular polygon

    Regular polygon Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)T ...

  5. 2017ACM暑期多校联合训练 - Team 2 1011 HDU 6055 Regular polygon (数学规律)

    题目链接 **Problem Description On a two-dimensional plane, give you n integer points. Your task is to fi ...

  6. 2017 Multi-University Training Contest - Team 2 &hdu 6055 Regular polygon

    Regular polygon Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)T ...

  7. HDU 6055 - Regular polygon | 2017 Multi-University Training Contest 2

    /* HDU 6055 - Regular polygon [ 分析,枚举 ] 题意: 给出 x,y 都在 [-100, +100] 范围内的 N 个整点,问组成的正多边形的数目是多少 N <= ...

  8. HDU 6055 Regular polygon —— 2017 Multi-University Training 2

    Regular polygon Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)T ...

  9. 【2017多校训练2+计算几何+板】HDU 6055 Regular polygon

    http://acm.hdu.edu.cn/showproblem.php?pid=6055 [题意] 给定n个格点,问有多少个正多边形 [思路] 因为是格点,只可能是正方形 枚举正方形的对角线,因为 ...

随机推荐

  1. [css 实践篇] CSS box-orient

    定义和用法 box-orient 属性规定框的子元素应该被水平或垂直排列. 提示:水平框中的子元素从左向右进行显示,而垂直框的子元素从上向下进行显示.不过,box-direction 和 box-or ...

  2. Qt中的View Model模型

    原始日期: 2016-08-17 21:19 Qt中的View主要有三种QListView,QTreeView, QTabelView 而对应的Model是:QStringListModel, QAb ...

  3. Python入门(2)

    一.    基础语法 1.Print print 是 python 里很基本很常见的一个操作,它的操作对象是一个字符串. 直接在 print 后面加一段文字来输出的话,需要给文字加上双引号或者单引号. ...

  4. websocket多线程问题

    title: websocket多线程问题 date: 2017-06-28 11:21:24 categories: websocket tags: [websocket] --- 开发框架 spr ...

  5. java当中成员变量和局部变量的区别

    1:成员变量定义在类中,整个类中都可以访问.2:局部变量定义在函数,语句,局部代码块中,只在所属的区域有效.3:成员变量存在于堆内存的对象中.4:局部变量存在于栈内存的方法中.5:成员变量随着对象的创 ...

  6. JAVA IO流结构图

    InputStreamReader和OutputStreamWriter分别继承自java.io包中的Reader和Writer,对他们中的抽象的未实现的方法给出实现.如: public int re ...

  7. template might not exist or might not be accessible by any of the configured Template Resolvers

    距离上一篇文章已经很长时间了,最近太忙碌了,今天发布spring boot遇到一个问题,找了好久才找到解决办法,今天贴出来和大家一起分享下,首先看错误信息 HTTP Status 500 - Requ ...

  8. Ionic 常用组件解析

    Ionic 常用组件解析 $ionicModal(弹出窗口): //创建一个窗口 //此处注意目录的起始位置为app $ionicModal.fromTemplateUrl('app/security ...

  9. 使用docker-compose搭建AspNetCore开发环境

    1 使用docker-compose搭建开发环境 我们的目标很简单:使用docker-compose把若干个docker容器组合起来就成了. 首先使用Nginx代理所有的Web程序,这样只需要在主机上 ...

  10. AugularJS从入门到实践(一)

      前  言  前端    AngularJS是为了克服HTML在构建应用上的不足而设计的.(引用百度百科) AngularJS使用了不同的方法,它尝试去补足HTML本身在构建应用方面的缺陷.Angu ...