您的位置:首页 > 编程语言 > Go语言

HDU 2017 多校联赛2 1011 Regular polygon

2017-07-28 17:57 375 查看


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



0 0 

0 1 

1 0 

1 1 



0 0 

0 1 

1 0 

1 1 

2 0 

2 1


Sample Output



2


题目大意:

给一个数n,接下来有n个点,求这些点能组成几个正方形。


c++

#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
int m[500][500];
struct Point
{
int x,y;
}s[555];
int solve(Point a,Point b)
{
int x=a.x-b.x;
int y=a.y-b.y;
int ans=0;
if(a.x+y>=0&&a.y-x>=0&&b.x+y>=0&&b.y-x>=0&&m[a.x+y][a.y-x]&&m[b.x+y][b.y-x])
ans++;
if(a.x-y>=0&&a.y+x>=0&&b.x-y>=0&&b.y+x>=0&&m[a.x-y][a.y+x]&&m[b.x-y][b.y+x])
ans++;
return ans;
}
int main()
{
int n,a,b;
while(~scanf("%d",&n))
{
memset(m,0,sizeof(m));
for(int i=0; i<n; i++)
{
scanf("%d%d",&a,&b);
a+=200;
b+=200;
s[i].x=a;
s[i].y=b;
m[a][b]=1;
}
int ans=0;
for(int i=0; i<n; i++)
for(int j=i+1; j<n; j++)
if(i!=j)
ans+=solve(s[i],s[j]);
printf("%d\n",ans/4);
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: