Regular polygon

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

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
 
Source
 
Recommend
liuyiding   |   We have carefully selected several similar problems for you:  6055 6054 6053 6052 6051 
/*
* @Author: Lyucheng
* @Date: 2017-07-27 14:26:58
* @Last Modified by: Lyucheng
* @Last Modified time: 2017-07-28 15:43:15
*/
/*
题意:给你一个点阵,让你找多边形的个数,因为点都是整数所以只可能是正方形
*/ #include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <time.h> #define MAXN 5005
#define MAXM 2005
#define EXP 1e-6
using namespace std; struct Point{
int x,y;
Point(){}
Point(int _x,int _y){
x=_x;
y=_y;
}
bool operator < (const Point & other) const{
if(x==other.x)
return y<other.y;
return x<other.x;
}
}point[MAXN];
int n;
bool vis[MAXM][MAXM]; bool ok(Point a,Point b){//对点
double ax=(a.x+a.y+b.x-b.y)*1.0/;
double ay=(-a.x+a.y+b.x+b.y)*1.0/;
double bx=(a.x-a.y+b.x+b.y)*1.0/;
double by=(a.x+a.y-b.x+b.y)*1.0/; if(ax-(int)ax>EXP||bx-(int)bx>EXP||ay-(int)ay>EXP||by-(int)by>EXP)
return false;
if(ax<||ay<||bx<||by<)
return false; if(vis[(int)ax][(int)ay]==true&&vis[(int)bx][(int)by]==true)
return true;
return false;
} inline void init(){
memset(vis,false,sizeof vis);
} int main(){
// freopen("in.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
while(scanf("%d",&n)!=EOF){
init();
for(int i=;i<n;i++){
scanf("%d%d",&point[i].x,&point[i].y);
point[i].x+=;
point[i].y+=;
vis[point[i].x][point[i].y]=true;
}
sort(point,point+n);
int res=;
for(int i=;i<n;i++){
for(int j=i+;j<n;j++){
if(ok(point[i],point[j])==true){
res++;
}
}
}
printf("%d\n",res/);
}
return ;
}

HDU 6055 Regular polygon的更多相关文章

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

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

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

  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 —— 2017 Multi-University Training 2

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

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

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

  6. HDU 6055 Regular polygon (暴力)

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

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

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

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

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

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

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

随机推荐

  1. Bootstrap框架的了解和使用之栅格系统

       前    言 Bootstrap Bootstrap 包含了一个响应式的.移动设备优先的.不固定的网格系统,可以随着设备或视口大小的增加而适当地扩展到 12 列.它包含了用于简单的布局选项的预定 ...

  2. BZOJ2748_音量调节_KEY

    [HAOI2012]音量调节 Time Limit: 3 Sec Memory Limit: 128 MB Description 一个吉他手准备参加一场演出.他不喜欢在演出时始终使用同一个音量,所以 ...

  3. java 面向对象 1

    目录 一.面向过程的思想和面向对象的思想 二.简单理解面向对象 三.面向对象的设计思想 四.对象和类的概念 五.如何抽象出一个类? 六.类(对象)之间的关系 七.Java与面向对象 八.为什么使用面向 ...

  4. AngularJS -- Bootstrap(启动器)(转载)

    AngularJS -- Bootstrap(启动器)   点击查看AngularJS系列目录 转载请注明出处:http://www.cnblogs.com/leosx/ Bootstrap(初始化) ...

  5. AngularJS--控制器(Controller)

    点击查看AngularJS系列目录 转载请注明出处:http://www.cnblogs.com/leosx/ 理解控制器 在AngularJS的控制器中,构造函数会有Scope参数. 当一个控制器通 ...

  6. Spring中的Service/DAO/DTO

  7. iOS连续dismiss几个ViewController的方法

    原文链接:http://blog.csdn.net/longshihua/article/details/51282388 presentViewController是经常会用到的展现ViewCont ...

  8. ThinkPHP中:RBAC权限控制的实习步骤

    使用版本ThinkPHP3.1.3 第一步,建表及数据 第二步,建关联模型 第三步,控制器使用关联模型.配置文件 第四步,模板显示数据 第一步,建表及数据 在数据库中,建立一个companysvn数据 ...

  9. 《深入理解Java虚拟机》读书笔记-垃圾收集器与内存分配策略

    在堆里存放着java世界中几乎所有的对象实例,垃圾收集器在对堆进行回收前需要知道哪些对象还存活,哪些对象已经死去.那怎么样去判断对象是否存活呢? 一.判断对象是否存活算法 1.引用计数法 实现思路:给 ...

  10. Bayesian CTR Prediction for Bing

    Microsoft published a paper in ICML 2009 named ‘Web-Scale Bayesian Click-Through Rate Prediction for ...