Pagini recente » Cod sursa (job #103886) | Cod sursa (job #2103992) | Cod sursa (job #702453) | Cod sursa (job #2201019) | Cod sursa (job #811056)
Cod sursa(job #811056)
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#define eps 1e-14
#define inf 2000000000
using namespace std;
class POINT {
private:
long x;
long y;
public:
POINT(){}
void set(long a, long b){
x=a;
y=b;
}
long gx ()
{
return x;
}
long gy ()
{
return y;
}
friend double panta (POINT &P1, POINT &P2){
if(P2.x==P1.x)
return inf;
return (double)((double)P2.y-P1.y)/(P2.x-P1.x);
}
};
POINT P[1001];
double pante[1000*1001];
long a,b,k,n,i,j,num;
bool cmp (double x, double y)
{
return x-y<-eps;
}
int main () {
freopen("trapez.in","r",stdin);
freopen("trapez.out","w",stdout);
scanf("%ld",&n);
for(i=1;i<=n;i++)
{
scanf("%ld%ld",&a,&b);
P[i].set(a,b);
}
for(i=1;i<=n;i++)
for(j=1;j<i;j++)
pante[++num]=panta(P[i],P[j]);
sort(pante+1,pante+num+1,cmp);
pante[++num]=inf;
long l=1,s=0;
for(i=1;i<num;i++)
if(fabs(pante[i+1]-pante[i])<eps)
l++;
else
{
s+=l*(l-1)/2;
l=1;
}
printf("%ld\n",s);
return 0;
}