题意: 给出若干个点,找到有多少个正多边形
思路:
构造了下,发现在整数点上似乎没有找到除了正四边形之外的正多边形。那么就枚举一下就好了!
#include <stdio.h>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <set>
using namespace std;
struct node {
int x, y;
bool friend operator < (node a, node b) {
if(a.x != b.x)
return a.x < b.x;
return a.y < b.y;
}
} nod[505];
int main (void) {
ios::sync_with_stdio(false);
int n;
while(cin>>n) {
set<node> st;
for(int i=1; i<=n; ++i) {
cin>>nod[i].x>>nod[i].y;
nod[i].x *= 2;
nod[i].y *= 2;
st.insert(nod[i]);
}
sort(nod+1, nod+1+n);
int ans = 0;
for(int i=1; i<=n; ++i) {
for(int j=1; j<i; ++j) {
int x = (nod[i].x + nod[j].x) / 2;
int y = (nod[i].y + nod[j].y) / 2;
int y1 = x - nod[i].x + y;
int x1 = nod[i].y - y + x;
int y2 = nod[i].x - x + y;
int x2 = y - nod[i].y + x;
if(st.count((node){x1,y1}) && st.count((node){x2,y2}))
ans ++;
}
}
cout<<ans/2<<endl;
}
return 0;
}