Pagini recente » Cod sursa (job #1471102) | Cod sursa (job #587929) | Cod sursa (job #1133753) | Cod sursa (job #1714843) | Cod sursa (job #21598)
Cod sursa(job #21598)
#include <cstdio>
#include <algorithm>
#define maxn 1024
using namespace std;
struct point { long long x, y;};
struct nod { point a, b; long long mx, my;};
point x[maxn];
nod a[maxn*maxn];
int n, T;
void citire()
{
freopen("trapez.in", "r",stdin);
scanf("%d\n", &n);
for(int i=1;i<=n;i++) scanf("%lld %lld\n", &x[i].x, &x[i].y);
}
bool operator<(const nod &a, const nod &b)
{
if(a.my*b.mx<a.mx*b.my) return 1;
return 0;
}
bool operator ==(const point &a, const point &b)
{
if(a.x==b.x&&a.y==b.y) return 1;
return 0;
}
void calcul()
{
int i, j;
for(i=1;i<n;i++)
for(j=i+1;j<=n;j++)
{
++T;
a[T].a=x[i];
a[T].b=x[j];
a[T].mx=(long long)x[i].x-x[j].x;
a[T].my=(long long) x[i].y-x[j].y;
}
sort(a+1, a+T+1);
long long s=0;
int t=1;
for(i=2;i<=T;i++)
{
if(a[i].a==a[i-1].a || a[i].b==a[i-1].b)continue;
if((long long)a[i-1].my*a[i].mx==(long long)a[i-1].mx*a[i].my)
t++;
else
{
s+=(long long) t*(t-1)/2;
t=1;
}
}
s+=(long long) t*(t-1)/2;
freopen("trapez.out", "w", stdout);
printf("%lld\n", s);
}
int main()
{
citire();
calcul();
return 0;
}