暴力枚举中心点和对称的线段,注意点在线段上的情况,以及许多点都在一条直线上的情况。
#include<bits/stdc++.h>
#define pb push_back
#define fuck(x) cout<<'['<<#x<<' '<<x<<']'<<endl
using namespace std;
typedef long long ll;
#define mp make_pair
#define pii pair<int,int>
#define debug(x) cout<<#x<<" = "<<x<<endl;
#define fi first
#define se second
#define clr(x,y) memset(x,y,sizeof(x))
const int mod = 175781251;
const int MAXN = 1e6 + 2;
const int MX = 1e3 + 7;
map<pii, int> dot;
map<pair<pii, pii>, int> line;
struct Point {
int x, y;
Point() {}
Point(int x, int y): x(x), y(y) {}
void read() {
scanf("%d%d", &x, &y);
}
} P[MX];
int main() {
#ifdef LOCAL
freopen("in.txt", "r", stdin);
#endif
int n;
scanf("%d", &n);
for(int i = 1; i <= n; i++) {
P[i].read();
}
for(int i = 1; i <= n; i++) {
dot[mp(P[i].x*2, P[i].y*2)]++;
for(int j = i + 1; j <= n; j++) {
pii d = mp(P[i].x + P[j].x, P[i].y + P[j].y);
dot[d] += 2;
int xx = P[i].x - P[j].x, yy = P[i].y - P[j].y;
int g = __gcd(xx, yy);
xx /= g;
yy /= g;
if(yy < 0) {
yy = -yy;
xx = -xx;
}
int x = yy, y = -xx;
pair<pii, pii> Li;
if(x == 0) {
Li = mp(mp(d.fi,0), mp(x, y));
}
else if(y == 0){
Li = mp(mp(0,d.se), mp(x, y));
}
else {
int k = d.fi/x + (d.fi%x< 0? 1 : 0);
Li = mp(mp(d.fi - k*x, d.se - k*y), mp(x, y));
}
line[Li] += 2;
}
}
int cnt = 0;
int ans = 1e9;
for(auto it = dot.begin(); it != dot.end(); it++) {
ans = min(ans,n - it->se);
}
for(auto it = line.begin(); it != line.end(); it++) {
int cnt = it->se;
for(int i = 1; i <= n; i++){
pii m = it->fi.fi;
pii v = it->fi.se;
pii t = mp(P[i].x*2, P[i].y*2);
if(v.fi == 0){
cnt += (t.fi == m.fi);
continue;
}
else if(v.se == 0){
cnt += (t.se == m.se);
continue;
}
t = mp(t.fi - m.fi, t.se - m.se);
cnt += (t == mp(0,0) || (t.fi/v.fi == t.se/v.se && t.fi%v.fi == 0 && t.se%v.se == 0));
}
ans = min(ans,n - cnt);
}
for(int i = 1; i <= n; i++){
for(int j = 1; j < i; j++){
int A = P[i].x - P[j].x;
int B = P[i].y - P[j].y;
int C = P[i].y*(P[i].x-P[j].x) - P[i].x*(P[i].y-P[j].y);
int cnt = 0;
for(int k = 1; k <= n; k++) {
if(-A*P[k].y + B*P[k].x + C == 0) cnt++;
}
ans = min(ans,n-cnt);
}
}
cout << ans << endl;
return 0;
}