Pagini recente » Profil Ruxandra985 | Istoria paginii utilizator/florinstelistu | Statistici Muresan Mircea Paul (Mirceamp) | Cod sursa (job #3146543) | Cod sursa (job #2076052)
#include <algorithm>
#include <fstream>
#include <set>
#include <vector>
using namespace std;
const int MAX_N = 1005;
const double INFINITE = 2e9;
const double EPSILON = 1.e-14;
vector<double> slopes;
pair<int, int> a[MAX_N];
double slope(const pair<int, int> &a, const pair<int, int> &b) {
if (a.first==b.first) {
return INFINITE;
}
return (1.0 * b.second - a.second) / (1.0 * b.first - a.first);
}
int main() {
ifstream cin("trapez.in");
ofstream cout("trapez.out");
int n;
cin >> n;
for (int i = 1; i <= n; ++ i) {
cin >> a[i].first >> a[i].second;
}
for (int i = 1; i <= n; ++ i) {
for (int j = i + 1; j <= n; ++ j) {
slopes.push_back(slope(a[i], a[j]));
}
}
sort(slopes.begin(),slopes.end());
int l = 1;
int total = 0;
for (int i = 1; i < (int)slopes.size(); ++ i) {
if (fabs(slopes[i] - slopes[i - 1]) < EPSILON) {
++ l;
} else {
total += l * (l - 1) / 2;
l = 1;
}
}
cout << total << "\n";
return 0;
}