将所有点的两两的中心处理出来,看哪个点被用的最多用哪个
尊龙的代码~
#include<bits/stdc++.h>
using namespace std;
struct point{
int x,y;
} p[1010];
struct {
int x,y,cnt=-1;
} ha[10000010];
int num,n;
long long h=10000007;
int get(int x, int y){
long long o=x,oo=y;
o=abs(o*o^oo*7+o*10007+oo*oo*4567867+oo*3+87653)%h;
//printf("%d\n",o);
int t=o;
while (ha[t].cnt!=-1) {
if (ha[t].x==x&&ha[t].y==y) return t;
t=(t+1)%h;
}
ha[t].x=x;
ha[t].y=y;
ha[t].cnt=0;
return t;
}
int main(){
scanf("%d",&n);
num=-1;
for (int i=1;i<=n;i++){
scanf("%d%d",&p[i].x,&p[i].y);
ha[get(p[i].x*2,p[i].y*2)].cnt+=1;
num=max(ha[get(p[i].x*2,p[i].y*2)].cnt,num);
//printf("%d %d %d\n",p[i].x*2,p[i].y*2,ha[get(p[i].x*2,p[i].y*2)].cnt);
}
for (int i=1;i<=n;i++){
for (int j=i+1;j<=n;j++){
ha[get(p[i].x+p[j].x,p[i].y+p[j].y)].cnt+=2;
num=max(ha[get(p[i].x+p[j].x,p[i].y+p[j].y)].cnt,num);
//printf("%d %d %d\n",p[i].x+p[j].x,p[i].y+p[j].y,ha[get(p[i].x+p[j].x,p[i].y+p[j].y)].cnt);
}
}
printf("%d\n",n-num);
return 0;
}