Pagini recente » Cod sursa (job #2669704) | Cod sursa (job #1069274) | Cod sursa (job #1351376) | Cod sursa (job #1359171) | Cod sursa (job #1981423)
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
struct point
{
double x,y;
};
vector<point>v;
vector <double>v1;
const double eps=1.e-14;
const double INF=2.e9;
double panta(point a,point b)
{
if(fabs(a.x-b.x)<eps)return INF;
return (b.y-a.y)/(b.x-a.x);
}
int main()
{
freopen("trapez.in","r",stdin);
freopen("trapez.out","w",stdout);
int n , i,nr1;
double x, y;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%lf %lf",&x,&y);
point nr;
nr.x=x;
nr.y=y;
v.push_back(nr);
}
int sum=0;
vector<point>::iterator it;
vector<point>::iterator it1;
point a,b;
for(it=v.begin();it!=v.end();it++)
{
for(it1=it+1;it1!=v.end();it1++)
{
a=*it;
b=*it1;
v1.push_back(panta(a,b));
}
}
sort(v1.begin(),v1.end());
int cnt=0;
sum=0;
vector<double>::iterator x1;
vector<double>::iterator y1;
for(x1=v1.begin();x1!=v1.end();x1++)
{
y1=x1;
double t=(*y1);
cnt=0;
while(y1!=v1.end()&&t==(*y1))
{
cnt++;
y1++;
}
x1=y1-1;
sum+=(cnt*(cnt-1))/2;
}
printf("%d",sum);
return 0;
}