Pagini recente » Cod sursa (job #2747699) | Cod sursa (job #60521) | Cod sursa (job #1591622) | Cod sursa (job #2453506) | Cod sursa (job #2422275)
#include <bits/stdc++.h>
using namespace std;
ifstream in("trapez.in");
ofstream out("trapez.out");
struct pct{
double x,y;
};
int nrPct,r,t=1;
pct p[1005];
vector <double> panta;
int main(){
ios::sync_with_stdio(0);
in>>nrPct;
for(int i = 1; i <= nrPct; ++i) in>>p[i].x>>p[i].y;
for(int i = 1; i < nrPct; ++i)
for(int j = i + 1; j <= nrPct; ++j)
if(p[j].x - p[i].x == 0) panta.push_back(INT_MAX - 1);
else panta.push_back((p[j].y - p[i].y) / (p[j].x - p[i].x));
sort(panta.begin(), panta.end());
for(int i = 1; i < panta.size(); ++i)
if(panta[i] == panta[i - 1]) ++t;
else r += (t * (t - 1)) / 2, t = 1;
out<<r + (t * (t - 1)) / 2;
return 0;
}