Pagini recente » Cod sursa (job #515451) | Cod sursa (job #102308) | Cod sursa (job #2453021) | Cod sursa (job #550625) | Cod sursa (job #1494804)
#include <cstdio>
#include <iostream>
#include <set>
#include <climits>
#include <map>
#include <algorithm>
using namespace std;
bool f(pair<long long, long long> a, pair<long long, long long> b) {
return (a.second * b.first < a.first * b.second);
}
bool g(pair<long long, long long> a, pair<long long, long long> b) {
return (a.second * b.first == a.first * b.second);
}
int main() {
freopen("trapez.in", "r", stdin);
freopen("trapez.out", "w", stdout);
ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
long long x[1005], y[1005];
for (int i = 1; i <= n; i++) {
cin >> x[i] >> y[i];
}
pair<long long, long long> v[1000005];
int l = n * (n - 1) / 2, c = 1;
for (int i = 1; i < n; i++) {
for (int j = i + 1; j <= n; j++, c++) {
v[c].first = x[i] - x[j];
v[c].second = y[i] - y[j];
}
}
sort(v + 1, v + l + 1, f);
long long ans = 0;
for (int i = 1; i <= l; i++) {
int j = i + 1;
c = 1;
while (j <= l && g(v[i], v[j])) {
c++;
j++;
}
ans += c * (c - 1) / 2;
}
cout << ans;
return 0;
}