Pagini recente » Cod sursa (job #954787) | Cod sursa (job #2073451) | Autentificare | Cod sursa (job #1107768) | Cod sursa (job #1649376)
#include <iostream>
#include <fstream>
#include <algorithm>
using namespace std;
ifstream f("trapez.in");
ofstream g("trapez.out");
long n,nr,c=1,el;
struct pct{int x,y;} a[1002],pante[499501];
bool cmp(pct a,pct b)
{
if(a.x<b.x)
if(a.y<b.y)return true;
return false;
}
bool cmppante(pct a,pct b)
{
if(a.x*b.y<a.y*b.x) return true;
return false;
}
void citire()
{int i,j;
f>>n;
for( i=1;i<=n;i++)
f>>a[i].x>>a[i].y;
sort(a+1,a+n+1,cmp);
for(i=1;i<n;i++)
for(j=i+1;j<=n;j++)
{el++;
pante[el].y=a[i].y-a[j].y;
pante[el].x=a[i].x-a[j].x;
}
sort(pante+1,pante+el+1,cmppante);
}
void rez()
{int i;
citire();
for(i=1;i<el;i++)
if(pante[i].x*pante[i+1].y==pante[i].y*pante[i+1].x)
c+=1;
else
{
nr+=(c*(c-1)/2);
c=1;
}
g<<nr;
}
int main()
{
rez();
return 0;
}