4 0 0 0 1 1 0 1 1 6 0 0 0 1 1 0 1 1 2 0 2 1
1 2
题意是给了n个点,问着这个图中有多少个正多边形
因为所给出的坐标是整数,满足整这个条件的正多边形只有正方形,根据正方形交叉线判断是否存在对称点加一,由于一个正方形有两个交叉线所以结果除二。
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<math.h>
#include<algorithm>
#define LL long long
const int MAX=80005;
LL n;
struct node
{
int x,y;
}pos[505];
bool vis[600][600];
template <class T>
T min(T x,T y)
{
return (x<y)?x:y;
}
template <class T>
T max(T x,T y)
{
return (x>y)?x:y;
}
int main()
{
LL n;
int i,j;
LL sum=0;
while(scanf("%lld",&n)!=EOF)
{
sum=0;
memset(vis,0,sizeof(vis));
for(i=0;i<n;i++)
{
scanf("%d%d",&pos[i].x,&pos[i].y);
// pos[i].x+=205;
// pos[i].y+=205;
vis[pos[i].x][pos[i].y]=1;
}
for(i=0;i<n;i++)
{
for(j=i+1;j<n;j++)
{
double xx=(pos[i].x+pos[j].x)*1.0/2;
double yy=(pos[i].y+pos[j].y)*1.0/2;
double cx=(pos[i].x-pos[j].x)*1.0/2;
double cy=(pos[i].y-pos[j].y)*1.0/2;
if(xx-cy!=int(xx-cy)||yy+cx!=int(yy+cy)) continue;
if(vis[int(xx-cy)][int(yy+cx)]==1&&vis[int(xx+cy)][int(yy-cx)]==1) sum++;
}
}
printf("%lld\n",sum/2);
}
return 0;
}