Pagini recente » Cod sursa (job #2236838) | Cod sursa (job #742503) | Cod sursa (job #569848) | Cod sursa (job #1803666) | Cod sursa (job #2266632)
#include <bits/stdc++.h>
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;
struct fractie {
int sus, jos;
void normalize() {
if (jos == 0) {
sus = 1;
return;
}
if (sus == 0) {
jos = 1;
return;
}
int g = __gcd(sus, jos);
sus /= g;
jos /= g;
}
fractie(int x, int y) {
sus = x;
jos = y;
normalize();
}
bool operator<(const fractie &other) const {
return 1LL * sus * other.jos <
1LL * jos * other.sus;
}
};
map<fractie, 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[fractie(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;
}