Pagini recente » Cod sursa (job #2129003) | Cod sursa (job #2934119) | Cod sursa (job #2618765) | Cod sursa (job #2071162) | Cod sursa (job #1771739)
#include <cstdio>
#include <algorithm>
using namespace std;
struct punct
{
int x,y;
};
punct v[1010],v1[1000010];
int cmp(punct a,punct b)
{
return 1LL*a.x*b.y<1LL*a.y*b.x;
}
int main()
{
freopen("trapez.in","r",stdin);
freopen("trapez.out","w",stdout);
int n,l=0,s,r=0;
scanf("%d",&n);
for(int i=1;i<=n;i++)
scanf("%d%d",&v[i].x,&v[i].y);
for(int i=1;i<=n;i++)
for(int j=i+1;j<=n;j++)
{
l++;
v1[l].x=v[i].y-v[j].y;
v1[l].y=v[i].x-v[j].x;
}
sort(v1+1,v1+l+1,cmp);
s=1;
for(int i=1;i<=l;i++)
{
if(1LL*v1[i].x*v1[i+1].y==1LL*v1[i+1].x*v1[i].y) s++;
else
{
r=r+(s-1)*s/2;
s=1;
}
}
printf("%d",r);
return 0;
}