Pagini recente » Cod sursa (job #933805) | Cod sursa (job #656597) | Cod sursa (job #1025904) | Cod sursa (job #935600) | Cod sursa (job #2221319)
#include <bits/stdc++.h>
#define INF (1e9)
const double eps = (1e-14);
using namespace std;
class POINT
{
private:
int x,y;
public:
POINT()
{
x=0;
y=0;
};
POINT(int _x,int _y)
{
x=_x;
y=_y;
};
POINT(const POINT &other)
{
x=other.x;
y=other.y;
};
void set(int x1,int y1)
{
x=x1;
y=y1;
}
double dist (const POINT &other)
{
return sqrt((x-other.x)*(x-other.x)+(y-other.y)*(y-other.y));
}
bool operator == (const POINT &other)
{
return (fabs(x-other.x)<eps&&fabs(y-other.y)<eps);
}
bool operator != (const POINT &other)
{
return !(fabs(x-other.x)<eps&&fabs(y-other.y)<eps);
}
double panta (const POINT &other)
{
if(fabs(x-other.x)<eps)
return INF;
return 1.0*(y-other.y)/(x-other.x);
}
};
POINT v[1005];
double ddiisstt[1005*1005];
int main()
{
freopen("trapez.in","r",stdin);
freopen("trapez.out","w",stdout);
int n,k=0;
scanf("%d",&n);
for(int i=1;i<=n;++i)
{
int xx,yy;
scanf("%d %d",&xx,&yy);
v[i].set(xx,yy);
}
for(int i=1;i<=n;++i)
{
for(int j=i+1;j<=n;++j)
{
ddiisstt[++k]=v[i].panta(v[j]);
}
}
sort(ddiisstt+1,ddiisstt+k+1);
int sum=0;
int cnt=0;
for(int i=1;i<=k;++i)
{
cnt=0;
while(fabs(ddiisstt[i]-ddiisstt[i-1])<eps)
{
cnt++;
i++;
}
sum+=((cnt+1)*cnt)/2;
}
sum+=((cnt+1)*cnt)/2;
printf("%d",sum);
return 0;
}