Pagini recente » Cod sursa (job #611459) | Cod sursa (job #1012960) | Cod sursa (job #2441735) | Cod sursa (job #1647822) | Cod sursa (job #1648100)
#include <cstdio>
#include <algorithm>
using namespace std;
struct punct{int x,y;};
punct v[1005];
punct panta[1000005];
int modul(int a)
{
if(a<0)
a=a*(-1);
return a;
}
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;
}
bool cmp(punct a, punct b)
{
if(a.x>b.x)
return true;
else
if(a.x<b.x)
return false;
else
if(a.y<b.y)
return true;
else
return false;
}
int main(){
freopen("trapez.in" , "r" , stdin);
freopen("trapez.out" , "w" , stdout);
int n,i,j,k,cate,sol,w;
scanf("%d" , &n);
for(i=1; i<=n; i++)
scanf("%d%d" , &v[i].x, &v[i].y);
sort(v+1, v+n+1, cmp);
k=0;
for(i=1;i<n;i++)
for(j=i+1;j<=n;j++)
{
k++;
panta[k].x=modul(v[i].x-v[j].x);
panta[k].y=modul(v[i].y-v[j].y);
if(panta[k].x!=0 && panta[k].y!=0)
{
w=cmmdc(panta[k].x, panta[k].y);
panta[k].x=panta[k].x/w;
panta[k].y=panta[k].y/w;
}
}
sort(panta+1, panta+k+1, cmp);
cate=1; sol=0;
for(i=1; i<=k; i++)
if(panta[i].x==panta[i+1].x && panta[i+1].y==panta[i].y)
cate++;
else
{
sol=sol+cate*(cate-1)/2;
cate=1;
}
sol=sol+cate*(cate-1)/2;
printf("%d" , sol);
return 0;
}