Pagini recente » Cod sursa (job #2289607) | Cod sursa (job #2207115) | Cod sursa (job #1851457) | Cod sursa (job #2263647) | Cod sursa (job #2204558)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("trapez.in");
ofstream fout("trapez.out");
const double E = 1e-15;
vector <double> p;
struct st {int x, y;} v[1001];
double panta(int i, int j) {
return (double)(v[i].y - v[j].y) / (v[i].x - v[j].x);
}
int main()
{
int n, nrx = 0, ans = 0;
fin >> n;
for(int i = 0; i < n; i++)
fin >> v[i].x >> v[i].y;
for(int i = 0; i < n; i++) {
for(int j = i + 1; j < n; j++) {
if(v[i].x == v[j].x)
nrx++;
else
p.push_back(panta(i, j));
}
}
ans += nrx * (nrx - 1) >> 1;
sort(p.begin(), p.end());
for(vector<double> :: iterator it = p.begin(); it != p.end(); it++) {
int nr = 1;
while(fabs(*it - *(it + 1)) < E)
it++, nr++;
ans += nr * (nr - 1) >> 1;
}
fout << ans;
fin.close();
fout.close();
return 0;
}