Pagini recente » Cod sursa (job #1750315) | Profil razzykk | Cod sursa (job #2149448) | Cod sursa (job #1273640) | Cod sursa (job #2221291)
#include <fstream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
using namespace std;
ifstream fin("trapez.in");
ofstream fout("trapez.out");
const double eps=1.e-14;
const double INF=1.e9;
class POINT
{
private : int x,y;
public:
POINT()
{
x=y=0;
}
POINT(int _x,int _y)
{
x=_x;
y=_y;
}
POINT set(int _x,int _y)
{
x=_x;
y=_y;
}
int getx()
{
return x;
}
int gety()
{
return y;
}
friend double panta(const POINT &a,const POINT &b)
{
if(a.x-b.x==0)
return INF;
double m=(double)(a.y-b.y),n=(double)(a.x-b.x);
return m/n;
}
};
POINT f[1005];
double p[500005];
int main()
{
int n,u,v,nr=0,r=0,smax=0;
fin>>n;
for(int i=1;i<=n;i++)
{
fin>>u>>v;
f[i].set(u,v);
}
for(int i=1;i<=n;i++)
{
for(int j=i+1;j<=n;j++)
{
nr++;
p[nr]=panta(f[i],f[j]);
//fout<<p[nr]<<endl;
}
}
sort(p+1,p+nr+1);
double y=p[1];
r=1;
for(int i=2;i<=nr;i++)
{
if(p[i]-y<eps)
{
r++;
}
else
{
smax+=r*(r-1)/2;
r=1;
y=p[i];
//fout<<r<<endl;
}
}
if(r!=1)
smax+=r*(r-1)/2;
//fout<<r<<endl;
fout<<smax;
return 0;
}