Regular polygon HDU 6055

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 

思路:

题意是给了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;
}





评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值