Regular polygon

Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 2219    Accepted Submission(s): 880

Problem 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 Input
4
0 0
0 1
1 0
1 1
6
0 0
0 1
1 0
1 1
2 0
2 1
 
Sample Output
1 2

题目大意:有n个点,问总共能形成多少个正多边形。

思路:实际上只能形成正四边形,在官方题解里给出了相关的论文。。。然后就变成了一道水题,暴力枚举点对,查找每个点对是否有对应的点对形成正方形。由于坐标存在负数,对输入数据做一下处理,以及注意横(纵)坐标差值<=200,注意到这两点基本没问题了。具体看代码。

AC代码:

 #include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
using namespace std;
struct Node{
int x;
int y;
}node[];
bool vis[][];
int main()
{
int n,dx,dy,a,b;
while(~scanf("%d", &n))
{
int res=;
memset(vis, , sizeof(vis));
for(int i=;i<n;i++){
scanf("%d%d", &a, &b);
a+=;
b+=;
node[i].x=a;
node[i].y=b;
vis[node[i].x][node[i].y]=;
} for(int i=;i<n;i++)
for(int j=i+;j<n;j++){
dx=node[i].x-node[j].x;
dy=node[i].y-node[j].y;
if(vis[node[i].x+dy][node[i].y-dx]==&&vis[node[j].x+dy][node[j].y-dx]==)
res++;
if(vis[node[i].x-dy][node[i].y+dx]==&&vis[node[j].x-dy][node[j].y+dx]==)
res++; }
cout<<res/<<endl;
}
}

HDU 6055 Regular polygon —— 2017 Multi-University Training 2的更多相关文章

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

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

  2. hdu 6055 : Regular polygon (2017 多校第二场 1011) 【计算几何】

    题目链接 有个结论: 平面坐标系上,坐标为整数的情况下,n个点组成正n边形时,只可能组成正方形. 然后根据这个结论来做. 我是先把所有点按照 x为第一关键字,y为第二关键字 排序,然后枚举向量 (p[ ...

  3. 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 ...

  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多校训练2+计算几何+板】HDU 6055 Regular polygon

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

  7. HDU 6055 Regular polygon (暴力)

    题意,二维平面上给N个整数点,问能构成多少个不同的正多边形. 析:容易得知只有正四边形可以使得所有的顶点为整数点.所以只要枚举两个点,然后去查找另外两个点就好. 代码如下: #pragma comme ...

  8. HDU 6170 - Two strings | 2017 ZJUT Multi-University Training 9

    /* HDU 6170 - Two strings [ DP ] | 2017 ZJUT Multi-University Training 9 题意: 定义*可以匹配任意长度,.可以匹配任意字符,问 ...

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

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

随机推荐

  1. poj1258Agri-Net(最小生成树)

    题目链接:http://poj.org/problem?id=1258 Description Farmer John has been elected mayor of his town! One ...

  2. 微信小程序(一)--微信小程序的介绍

    一.微信小程序简介 小程序是一种不需要下载安装即可使用的应用,它实现了应用“触手可及”的梦想,用户扫一扫或者搜一下即可打开应用.也体现了“用完即走”的理念,用户不用关心是否安装太多应用的问题.应用将无 ...

  3. 二叉树BinTree4种遍历及其应用

    前序遍历 template<class T> void BinTree<T>::PreOrder(BinTreeNode<T>*subTree){ //前序遍历以s ...

  4. Codeforces 433A (背包)

    题面 传送门 真是令人胃疼的题面 我不管,我要把苹果都给雪菜!(滑稽)(冬马党不要打我) 分析 突然感觉这题跟今年NOIP Day1T2有点像,都是根据数加减来构造背包,只不过这题是01背包而不是完全 ...

  5. pjhp实现使用redis来存储session数据

    #设置php处理session的方式为redis,并配置redis的访问地址(因为在redis中绑定的访问地址为127.0.0.1,所以就没有设置访问密码,如果需要请自行搜索)#因为不想修改php.i ...

  6. P2172 [国家集训队]部落战争(最小路径覆盖)

    P2172 [国家集训队]部落战争 每个点仅走一次:最小路径覆盖 套路地拆点,具体看代码中的$draw()$ 流量每增加1,意味着一支军队可以多走一格,代价减少1 最后答案即为总点数$-dinic() ...

  7. JDK8之ArrayList源码

    ArrayList三个构造器 /** * Default initial capacity. */ private static final int DEFAULT_CAPACITY = 10; // ...

  8. metasploit下Windows的多种提权方法

    metasploit下Windows的多种提权方法 前言 当你在爱害者的机器上执行一些操作时,发现有一些操作被拒绝执行,为了获得受害机器的完全权限,你需要绕过限制,获取本来没有的一些权限,这些权限可以 ...

  9. 20191101php日期练习

    <?phpecho abs(-23);echo "<hr/>";echo date("t");echo "<hr/>&q ...

  10. facenet 人脸识别(二)——创建人脸库搭建人脸识别系统

    搭建人脸库 选择的方式是从百度下载明星照片 照片下载,downloadImageByBaidu.py # coding=utf-8 """ 爬取百度图片的高清原图 &qu ...