Pagini recente » Cod sursa (job #440165) | Cod sursa (job #451647) | Cod sursa (job #1027804) | Cod sursa (job #1728419) | Cod sursa (job #2220672)
#include <fstream>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;
ifstream fin("trapez.in");
ofstream fout("trapez.out");
vector <double> v;
const double eps=1.e-14;
const double INF=1.e9;
class POINT
{
private:
double x,y;
public:
POINT()
{
x=y=0;
}
POINT(double _x, double _y)
{
x=_x;
y=_y;
}
POINT(const POINT &other)
{
x=other.x;
y=other.y;
}
void set(double _x, double _y)
{
x=_x;
y=_y;
}
double getx()
{
return x;
}
double gety()
{
return y;
}
double dist(const POINT &other)
{
return sqrt((x-other.x)*(x-other.x)+(y-other.y)*(y-other.y));
}
friend double dist(const POINT &p1, const POINT &p2)
{
return sqrt((p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y));
}
POINT mijloc(const POINT &other)
{
POINT temp;
temp.x=(x+other.x)*0.5;
temp.y=(y+other.y)*0.5;
return temp;
}
double panta(const POINT &other)
{
if(fabs(x-other.x)<eps)
return INF;
else
return (y-other.y)/(x-other.x);
}
};
POINT a[1005];
int main()
{
int i,n,j,k,z=1,cont=0,l,st,dr;double p,r;bool ok=1;
long long nr=0;
POINT temp;
fin>>n;
for(i=1;i<=n;i++)
{
fin>>j>>k;
temp.set(j,k);
a[i]=temp;
}
for(i=1;i<=n;i++)
{
for(j=i+1;j<=n;j++)
{
p=a[i].panta(a[j]);
v.push_back(p);
}
}
sort(v.begin(),v.end());
z=v.size();l=1;
for(i=1;i<z;i++)
{
if(fabs(v[i]-v[i-1])<eps)
l++;
else
{nr=nr+1ll*l*(l-1)/2;l=1;}
}
nr=nr+1ll*l*(l-1)/2;
fout<<nr;
return 0;
}