Pagini recente » Cod sursa (job #1261863) | Cod sursa (job #1584836) | Cod sursa (job #1077307) | Cod sursa (job #1322717) | Cod sursa (job #1388532)
#include <iostream>
#include <fstream>
#include<vector>
#define NMAX 1001
#include<algorithm>
using namespace std;
ifstream fin("trapez.in");
ofstream fout("trapez.out");
struct punct {
int x, y;
};
int n;
punct p[NMAX];
vector <double> v;
int main(){
fin>>n;
for (int i=1;i<=n;i++)fin>>p[i].x>>p[i].y;
double panta;
for (int i=2;i<=n;i++)
for (int j=1;j<i;j++) {
panta=(p[i].y-p[j].y)*1.0/(p[i].x-p[j].x);
v.push_back(panta);
}
sort(v.begin(),v.end());
int nr=1,sol=0;
for (int i=1;i<v.size();i++)
if (v[i]==v[i-1])nr++;
else{
sol+=nr*(nr-1)/2;
nr=1;
}
sol+=nr*(nr-1)/2;
fout<<sol;
return 0;
}