Pagini recente » Cod sursa (job #2693618) | Cod sursa (job #2431254) | Cod sursa (job #943377) | Cod sursa (job #2240222) | Cod sursa (job #1494839)
#include <cstdio>
#include <iostream>
#include <set>
#include <climits>
#include <map>
#include <algorithm>
#include <list>
#include <vector>
#include <utility>
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];
}
vector<pair<long long, long long> > v;
int l = n * (n - 1) / 2;
for (int i = 1; i < n; i++) {
for (int j = i + 1; j <= n; j++) {
int xc = x[i] - x[j];
int yc = y[i] - y[j];
if (yc < 0) {
yc = -yc;
xc = -xc;
}
pair<long long, long long> p = make_pair(xc, yc);
v.push_back(p);
}
}
sort(v.begin(), v.end(), f);
long long ans = 0;
for (int i = 0; i < l; i++) {
int j = i + 1;
int c = 1;
while (j < l && g(v[i], v[j])) {
c++;
j++;
}
ans += c * (c - 1) / 2;
}
cout << ans;
return 0;
}