Pagini recente » Cod sursa (job #1734632) | Cod sursa (job #1073122) | Cod sursa (job #1227811) | Cod sursa (job #2433952) | Cod sursa (job #2047694)
#include <cstdio>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;
const double eps=1.e-14;
const double INF=2.e9;
struct POINT{
int x,y;
};
vector <double> pant;
vector <POINT> points;
bool vertical(POINT P1, POINT P2)
{
return fabs(P1.x-P2.x)<eps;
}
double panta(POINT P1, POINT P2)
{
if(vertical(P1,P2))
return INF;
return (1.0*P2.y-P1.y)/(P2.x-P1.x);
}
int main()
{
freopen("trapez.in","r",stdin);
freopen("trapez.out","w",stdout);
int n;
POINT P;
scanf("%d",&n);
for(int y=1;y<=n;++y)
{
scanf("%d%d",&P.x,&P.y);
points.push_back(P);
}
double aux;
for(int i=0;i<points.size()-1;++i)
for(int j=i+1;j<points.size();++j)
{
aux=panta(points[i],points[j]);
pant.push_back(aux);
}
sort(pant.begin(),pant.end());
int l=1;
int sol=0;
for(int i=1;i<pant.size();++i)
{
if(fabs(pant[i]-pant[i-1])<eps)
l++;
else
{
sol+=(l*(l-1))/2;
l=1;
}
}
sol+=(l*(l-1))/2;
printf("%d",sol);
return 0;
}