/* -*- coding: utf-8 -*- * * 2769.cc: No.2769 Number of Rhombi - yukicoder */ #include #include #include #include using namespace std; /* constant */ const int MAX_N = 1000; const int MAX_M = MAX_N * (MAX_N - 1) / 2; /* typedef */ using ll = long long; using tp4 = tuple; using mtp4i = map; /* global variables */ int xs[MAX_N], ys[MAX_N]; tp4 es[MAX_M]; /* subroutines */ template T gcd(T m, T n) { // m >= 0, n >= 0 if (m < n) swap(m, n); while (n > 0) { T r = m % n; m = n; n = r; } return m; } void normalize(int &x, int &y) { if (x == 0) y = 1; else if (y == 0) x = 1; else if (x < 0) x = -x, y = -y; } /* main */ int main() { int n; scanf("%d", &n); for (int i = 0; i < n; i++) scanf("%d%d", xs + i, ys + i); mtp4i ecs; int m = 0; for (int i = 0; i < n; i++) for (int j = i + 1; j < n; j++) { int cx = xs[i] + xs[j], cy = ys[i] + ys[j]; int dx = xs[j] - xs[i], dy = ys[j] - ys[i]; if (dx == 0) dy = 1; int g = gcd(abs(dx), abs(dy)); if (g > 1) dx /= g, dy /= g; normalize(dx, dy); tp4 e(cx, cy, dx, dy); ecs[e]++; es[m++] = e; } ll sum = 0; for (int i = 0; i < m; i++) { auto [cx, cy, dx, dy] = es[i]; int rx = -dy, ry = dx; normalize(rx, ry); auto mit = ecs.find(tp4(cx, cy, rx, ry)); if (mit != ecs.end()) sum += mit->second; } printf("%lld\n", sum / 2); return 0; }