Pagini recente » Cod sursa (job #1381206) | Cod sursa (job #885461) | Cod sursa (job #2158520) | Cod sursa (job #122692) | Cod sursa (job #1645863)
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstdlib>
using namespace std;
struct eu{int x,y;};
eu v[1001],vc[1001],vec[1000001];
int i,j,n,m,k,cate,k1;
bool sorting(eu a,eu b)
{
if(a.x<b.x||a.x==b.x&&a.y<b.y)
return 1;
return 0;
}
int cmmdc(int a,int b)
{
int r;
if(a<b)
{
r=a;
a=b;
b=r;
}
while(b!=0)
{
r=a%b;
a=b;
b=r;
}
return a;
}
int main ()
{
freopen("trapez.in","r",stdin);
freopen("trapez.out","w",stdout);
scanf("%d",&n);
for(i=1;i<=n;i++)
scanf("%d%d",&v[i].x,&v[i].y);
sort(v+1,v+n+1,sorting);
for(i=1;i<n;i++)
for(j=i+1;j<=n;j++)
{
cate++;
vec[cate].x=v[j].x-v[i].x;
vec[cate].y=v[j].y-v[i].y;
k1=cmmdc(abs(vec[cate].x),abs(vec[cate].y));
vec[cate].x/=k1;
vec[cate].y/=k1;
}
sort(vec+1,vec+cate+1,sorting);
int l=1,s=0;
for(i=2;i<=cate;i++)
{
if(vec[i].x==vec[i-1].x&&vec[i].y==vec[i-1].y)
l++;
else
{
s+=l*(l-1)/2;
l=1;
}
}
printf("%d",s);
return 0;
}