Pagini recente » Cod sursa (job #528155) | Cod sursa (job #590551) | Cod sursa (job #86233) | Monitorul de evaluare | Cod sursa (job #1993401)
#include <iostream>
#include <set>
#include <vector>
#include <iomanip>
#include <fstream>
#include <algorithm>
#include <unordered_map>
using namespace std;
int n;
pair<int, int> v[1000 + 10];
ifstream fin("trapez.in");
ofstream fout("trapez.out");
unordered_map<double, int> u;
double panta(pair<int, int> a, pair<int, int> b) {
if(a.second != b.second) {
return (double)(a.first - b.first) / (double) (a.second - b.second);
}
return (double) (1 << 30);
}
void read() {
long long result = 0;
fin >> n;
for(int i = 1; i <= n; i++) {
fin >> v[i].first >> v[i].second;
}
fin.close();
for(int i = 1; i <= n; i++) {
for(int j = i + 1; j <= n; j++) {
u[panta(v[i], v[j])]++;
}
}
for(auto it = u.begin(); it != u.end(); it++) {
int val = it -> second;
result += (1LL * val * (val - 1)) / 2;
}
fout << result << endl;
fout.close();
}
int main() {
read();
return 0;
}