Pagini recente » Cod sursa (job #529343) | Cod sursa (job #2348996) | Cod sursa (job #2405325) | Cod sursa (job #1136133) | Cod sursa (job #1435827)
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
const double INF = 1.e+12;
const double eps = 1.e-14;
struct POINT
{
int x,y;
} v[1001];
double p[550000];
bool vertical(POINT A,POINT B)
{
return fabs(B.x-A.x)<eps;
}
double panta(POINT a,POINT b)
{
if(vertical(a,b))
return INF;
else
return ((double)b.y-a.y)/(b.x-a.x);
}
int main()
{
freopen("trapez.in","r",stdin);
freopen("trapez.out","w",stdout);
int n,i,j;
scanf("%d",&n);
for(i=1; i<=n; ++i)
scanf("%d%d",&v[i].x,&v[i].y);
int k=0,l=1;
long long t=0;
for (i=1; i<=n; ++i)
for (j=i+1; j<=n; ++j)
p[++k] = panta(v[i],v[j]);
sort (p+1, p+k+1);
for (i=2; i<=k; ++i)
{
if(fabs(p[i-1]-p[i])<eps)
l++;
else
{
t+=(long long)l*(l-1)/2;
l=1;
}
}
t+=(long long)l*(l-1)/2;
printf("%lld\n",t);
return 0;
}