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. idea live template高级知识, 进阶(给方法,类,js方法添加注释)(二)

    上一篇文章(http://www.cnblogs.com/xzjxylophone/p/6994488.html) 是在 groovyScript中直接添加的代码,这个看起来是简单,粗暴,麻烦和不美观 ...

  2. MongoDB一个基于分布式文件存储的数据库(介于关系数据库和非关系数据库之间的数据库)

    1:MongoDB的官方网址:https://www.mongodb.com   MongoDB的中文社区:http://www.mongoing.com/(老外也很看重中国市场啊,知道大家英语不好, ...

  3. oracle表空间自增长

    方式一:通过修改oracle database control 修改 第一步,点击开始--所有程序--Oracle - OraDb11g_home1--Database Control 第二步,通过g ...

  4. An overnight dance in discotheque

    An overnight dance in discotheque time limit per test 2 seconds memory limit per test 256 megabytes ...

  5. javaScript高级程序设计笔记 1

    核心  ECMAScript 文档对象模型  DOM 浏览器对象模型 BOM 延迟脚本  defer typeof操作符      判断字符类型  返回   undefined  boolean  s ...

  6. (cljs/run-at (JSVM. :browser) "搭建刚好可用的开发环境!")

    前言  书接上一回,在了解cljs基本语法后并在clojurescript.net的奇特错误提示后,我们必须痛定思痛地搭建一个本地的开发环境,以便后续深入地学习cljs. 现有的构建工具  由于浏览器 ...

  7. java亿级流量电商详情页系统的大型高并发与高可用缓存架构实战视频教程

    亿级流量电商详情页系统的大型高并发与高可用缓存架构实战 完整高清含源码,需要课程的联系QQ:2608609000 1[免费观看]课程介绍以及高并发高可用复杂系统中的缓存架构有哪些东西2[免费观看]基于 ...

  8. vue setTimeout用法 jquery滚动到某一个div的底部

    //vue 中setTimeOut用法 var $this = this; setTimeout(function(){ $this.goEnd() }, 10); goEnd:function(){ ...

  9. redis可视化工具redisClient

    下载连接:百度网盘 直接解压就可以用了

  10. 底层码农的Stanford梦 --- 从SCPD开始 [转]

    转载自知乎: https://zhuanlan.zhihu.com/p/25010074 一开始让我写这篇文章的时候,我是拒绝的.毕竟,我不是Stanford毕业的,出来写文章介绍Stanford,难 ...