Pagini recente » Cod sursa (job #2046891) | Cod sursa (job #128907) | Cod sursa (job #3221497) | Cod sursa (job #1742220) | Cod sursa (job #1095856)
#include <fstream>
#include <algorithm>
#define LL long long
using namespace std;
ifstream in("trapez.in"); ofstream out("trapez.out");
const int Nmax=1002;
int n,m;
LL nr=1,tot;
struct art {LL x,y;} P[Nmax];
art C[Nmax*(Nmax-1)/2];
bool egal(art &a, art &b)
{ return (a.x*b.y==b.x*a.y);}
bool cmp(const art &a, const art &b)
{ if (a.x*b.y==b.x*a.y) return 0;
bool r=(a.x*b.y<b.x*a.y);
if (b.y<0) r=!r;
if (a.y<0) r=!r;
return r;
}
int main ()
{ in>> n;
for(int i=1; i<=n; ++i) in>>P[i].x>>P[i].y;
for(int i=1; i<n; ++i)
for(int j=i+1; j<=n; ++j)
{C[++m].x=P[i].x-P[j].x; C[m].y=P[i].y-P[j].y;}
sort(C+1,C+m+1,cmp);
for(int i=2; i<=m; ++i)
if(egal(C[i-1],C[i])) ++nr;
else {tot += (nr*nr-nr)/2; nr=1;}
tot += (nr*nr-nr)/2;
out<<tot<<'\n'; out.close(); return 0;
}