Pagini recente » template/fmi-no-stress-10/header | Cod sursa (job #1376022) | Cod sursa (job #1376032) | Cod sursa (job #1525856) | Cod sursa (job #2613717)
#include<fstream>
#include<iostream>
#include<vector>
#include<algorithm>
#define EPS 1e-12
#define oo 2000001050.0
using namespace std;
vector<pair<int, int>> point;
vector<double> p;
int main() {
int n, x, y, j;
long long cnt;
ifstream fin("trapez.in");
ofstream fout("trapez.out");
fin >> n;
for(int i = 0; i < n; ++i) {
fin >> x >> y;
point.emplace_back(make_pair(x, y));
}
fin.close();
for(unsigned i = 0; i < point.size(); ++i) {
for(unsigned j = i + 1; j < point.size(); ++j)
if(point[i].first == point[j].first)
p.emplace_back(oo);
else p.emplace_back((double)(point[i].second - point[j].second) / (double)(point[i].first - point[j].first));
}
sort(p.begin(), p.end());
for(auto i : p)
cout << i << " ";
int i = 0;
cnt = 0;
while(i < n) {
j = 1;
i++;
while((i < n) && (p[i] - p[i - 1] < EPS)) {
j++;
i++;
}
cnt += (j * (long long)(j - 1)) / 2LL;
}
fout << cnt << "\n";
fout.close();
return 0;
}