题意略。
思路:要你找出所有正多边形,其实是唬人的,整点的正多边形只有正方形,具体证明可以参考 2017国家队论文集-《正多边形》-杨景钦
详见代码:
#include<bits/stdc++.h> #define maxn 505 //#define LOCAL using namespace std; struct Point{ int x,y; Point(int a = 0,int b = 0){ x = a,y = b; } Point operator+ (const Point& p){ return Point(x + p.x,y + p.y); } Point operator- (const Point& p){ return Point(x - p.x,y - p.y); } bool operator== (const Point& p) const{ return x == p.x && y == p.y; } bool operator< (const Point& p) const{ if(x != p.x) return x < p.x; return y < p.y; } }; struct line{ Point s,t; line(){} line(Point a,Point b){ s = a,t = b; } bool operator< (const line& l) const{ if(!(s == l.s)) return s < l.s; return t < l.t; } }; set<line> st; Point store[maxn * maxn]; int main(){ #ifdef LOCAL freopen("kkk.txt","r",stdin); freopen("kkkout.txt","w",stdout); #endif int n; while(scanf("%d",&n) == 1){ st.clear(); for(int i = 0;i < n;++i) scanf("%d%d",&store[i].x,&store[i].y); sort(store,store + n); for(int i = 0;i < n;++i){ for(int j = i + 1;j < n;++j){ st.insert(line(store[i],store[j])); } } int ans = 0; for(int i = 0;i < n;++i){ for(int j = i + 1;j < n;++j){ Point d = store[j] - store[i]; Point temp(d.y,-d.x); Point s = store[i] + temp; Point t = s + d; if(st.count(line(s,t))) ++ans; } } printf("%d ",ans / 2); } return 0; }