Pagini recente » Cod sursa (job #2736367) | Cod sursa (job #1284994) | Cod sursa (job #1953879) | Cod sursa (job #1320184) | Cod sursa (job #1706800)
#include <cstdio>
#include <cmath>
#include <algorithm>
#define MAXN 1000
#define MAXDR 500000
using namespace std;
const double INF=2.e9;
const double eps=1.e-14;
struct POINT{
int x, y;
}v[MAXN+5];
double p[MAXDR];
double panta(POINT P1, POINT P2){
if (fabs(P1.x-P2.x)<eps)
return INF;
else return 1.0*(P2.y-P1.y)/(P2.x-P1.x);
}
bool cmp(double a, double b){
return (a-b<=-eps);
}
int main(){
freopen("trapez.in", "r", stdin);
freopen("trapez.out", "w", stdout);
int n, i, j, k, lg, ans;
double pred;
scanf("%d", &n);
for (i=1; i<=n; i++)
scanf("%d%d", &v[i].x, &v[i].y);
k=0;
for (i=1; i<=n-1; i++)
for (j=i+1; j<=n; j++)
p[++k]=panta(v[i], v[j]);
sort(p+1, p+k+1, cmp);
pred=p[1];
lg=1;
ans=0;
for (i=2; i<=k; i++){
if (fabs(p[i]-pred)<eps){
lg++;
}
else{
ans+=lg*(lg-1)/2;
lg=1;
pred=p[i];
}
}
printf("%d", ans);
return 0;
}