Pagini recente » Cod sursa (job #2433124) | Cod sursa (job #2581343) | Cod sursa (job #2047705)
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
const double eps = 1.e-14;
const double INF = 2.e9;
struct POINT{
double x, y;
}v[1005];
bool vertical(POINT a, POINT b){
return fabs(a.x - b.x) < eps;
}
double panta(POINT a, POINT b){
if(vertical(a, b)){
return INF;
}
else
return (b.y - a.y) / (b.x - a.x);
}
double p[1000005];
int main()
{
freopen("trapez.in", "r", stdin);
freopen("trapez.out", "w", stdout);
int n, i, j, k, nr;
scanf("%d", &n);
for(i = 0;i < n;i++){
scanf("%lf%lf", &v[i].x, &v[i].y);
}
k = 0;
for(i = 0;i < n;i++){
for(j = i + 1;j < n;j++){
p[k] = panta(v[i], v[j]);
k++;
}
}
sort(p, p + k);
j = 1;
nr = 0;
for(i = 1;i < k;i++){
if(fabs(p[i] - p[i - 1]) > eps){
nr += j * (j - 1) / 2;
j = 0;
}
j++;
}
printf("%d", nr);
return 0;
}