2017 Multi-University Training Contest 2 1011

题意:给你最多500个坐标,坐标都为整数,让你求有多少个不同的正多边形数。

思路:正多边形一定是正方形,正方形的话,枚举两个点,找出另外两个点是否存在,最后结果除以4就是答案。


#include <stdio.h>
#include <stdlib.h>
#include <cmath>
#include <string.h>
#include <string>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <iostream>
#define LL long long
#define INF 0x3f3f3f3f
const int MAX_N = 5e2+10;
const LL mod = 1e9+7;
const double eps = 1e-6;
using namespace std;
struct Point
{
    int x,y;
}a[MAX_N];
int have[MAX_N][MAX_N];
int check(Point p1,Point p2)
{
    int dx = p1.x-p2.x;
    int dy = p1.y-p2.y;
    int ans = 0;
    if(p1.x+dy <= 200&&p1.x+dy >= 0&&p1.y-dx >= 0&&p1.y-dx <= 200&&p2.x+dy <= 200&&p2.x+dy >= 0
       &&p2.y-dx >= 0&&p2.y-dx <= 200&&have[p1.x+dy][p1.y-dx]&&have[p2.x+dy][p2.y-dx])
        ans++;
    if(p1.x-dy >= 0&&p1.x-dy <= 200&&p1.y+dx <= 200&&p1.y+dx >= 0&&p2.x-dy >= 0&&p2.x-dy <= 200
       &&p2.y+dx <= 200&&p2.y+dx >= 0&&have[p1.x-dy][p1.y+dx]&&have[p2.x-dy][p2.y+dx])
        ans++;
    return ans;
}
int main()
{
    int N;
    while(scanf("%d",&N)!=EOF)
    {
        memset(have,0,sizeof(have));
        for(int i = 0;i < N;i++)
        {
            scanf("%d%d",&a[i].x,&a[i].y);
            a[i].x+=100; a[i].y+=100;
            have[a[i].x][a[i].y] = 1;
        }
        int ans = 0;
        for(int i = 0;i < N;i++)
            for(int j = i+1;j < N;j++)
                 ans+=check(a[i],a[j]);
        cout<<ans/4<<endl;
    }
    return 0;
}
/*
*/


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值