Pagini recente » Cod sursa (job #2317745) | Istoria paginii runda/gr_5/clasament | Cod sursa (job #3149302) | Istoria paginii runda/page1supercontest/clasament | Cod sursa (job #2266645)
#include <bits/stdc++.h>
#include <unordered_map>
using namespace std;
typedef long long LL;
#define mp make_pair
#define CHECK(x) if(!(x)) return false;
#define CHECKRET(x, y) if(!(x)) return (y);
#define SKIP(x) if((x)) continue;
typedef pair<int, int> pii;
#ifdef INFOARENA
#define ProblemName "trapez"
#else
#define ProblemName "fis"
#endif
#define InFile ProblemName ".in"
#define OuFile ProblemName ".out"
const int MAXN = 1010;
pii v[MAXN];
int N;
LL hsh(int x, int y) {
if (x == 0)
y = 1;
else if (y == 0)
x = 1;
else {
int g = __gcd(x, y);
x /= g;
y /= g;
}
return 1LL * x * INT_MAX + y;
}
unordered_map<LL, int> pantaFreq;
int main() {
assert(freopen(InFile, "r", stdin));
assert(freopen(OuFile, "w", stdout));
scanf("%d", &N);
for (int i = 0; i < N; ++i) {
scanf("%d%d", &v[i].first, &v[i].second);
for (int j = i - 1; j >= 0; --j)
++pantaFreq[hsh(v[j].second - v[i].second,
v[j].first - v[i].first)];
}
int ans = 0;
for (const auto &it : pantaFreq)
ans += it.second * (it.second - 1) / 2;
printf("%d\n", ans);
return 0;
}