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. 前端工具-gulp-ruby-sass-解决带有中文路径报错(incompatible character encodings GBK and UTF-8)

    注意:错误提示真的是非常重要的!!! 今天 gulp 一个外国人的项目时编译 sass 时提示 Encoding::CompatibilityError: incompatible character ...

  2. mysql_DML_select_子查询

    -------------------------------------------------------------------子查询---------------------   --1.子查 ...

  3. 【MEAN Web开发】CentOS 7 安装MongoDB 3.2.3

    偶然得了一本书,AmosQ.Haviv 所著 <MEAN Web开发>.起初并不知道这啥东西,看了下目录发现正好有讲MongoDB而已.当时的项目正好需要做MongoDB的内容,之后这书就 ...

  4. windows mysql官方绿色版zip包安装教程

    环境: 系统环境 Windows 10 64位 mysql版本 5.7.19 一.万变不离的下载 下载页面:https://dev.mysql.com/downloads/mysql/ 点击 Down ...

  5. 快速测试端口的连通性(HTTP/HTTPS)

    ping 仅限 80 端口,命令中无法指定端口: C:\Users\Administrator>ping kikakika.com 遗失对主机的连接. 正在 Ping kikakika.com ...

  6. 16/8/21_PHP-有关类函数,this,static,面向对象思想介绍

    class_exists():判断某个类是否存在(定义过) interface_existe():判断接口是否存在 get_class():获取某个对象的"所属类名" get_pa ...

  7. stl vector创建二维数组

    vector<vector<); for (auto it = v.begin(); it != v.end(); it++) { ; (*it).reserve();//预留空间为5,但 ...

  8. poj3614Sunscreen

    Description To avoid unsightly burns while tanning, each of the C (1 ≤ C ≤ 2500) cows must cover her ...

  9. HeightCharts柱状图和饼状图

    HTML: <div id="container1"  style="height:350px; " ></div>    <di ...

  10. 牛顿迭代法理论推导及python代码实现

    公式不便于在这里编辑,所以在word中编辑好了,截图过来. 用python+牛顿迭代法   求 y =(x-2)**3的解 import numpy as np import matplotlib.p ...