Pagini recente » Cod sursa (job #86717) | Cod sursa (job #2976726) | Cod sursa (job #644404) | Cod sursa (job #774496) | Cod sursa (job #2237603)
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
const double eps=1.0e-14;
const double INF=2000000000;
struct POINT
{
int x,y;
};
double panta(POINT P1,POINT P2)
{
if(fabs(P2.x-P1.x)<eps)
return INF;
return (double)(P2.y-P1.y)/(P2.x-P1.x);
}
POINT p[1005];
double v[1000005];
int main()
{
freopen("trapez.in","r",stdin);
freopen("trapez.out","w",stdout);
int n,i,m=0,l=1,j,nr=0;
scanf("%d",&n);
for(i=1; i<=n; i++)
scanf("%d%d",&p[i].x,&p[i].y);
for(i=1; i<n; i++)
{
for(j=i+1; j<=n; j++)
{
m++;
v[m]=panta(p[i],p[j]);
}
}
sort(v+1,v+m+1);
for(i=2; i<=m; i++)
{
if(fabs(v[i]-v[i-1])<eps)
l++;
else
{
nr=nr+(l*(l-1))/2;
l=1;
}
}
printf("%d",nr);
return 0;
}