Pagini recente » Cod sursa (job #1698747) | Cod sursa (job #3005718) | Cod sursa (job #1037151) | Cod sursa (job #2266076) | Cod sursa (job #1703497)
#include <bits/stdc++.h>
using namespace std;
const double INF=2e9+5;
const double eps=1.e-14;
struct POINT {
double x, y;
};
vector <double> pan;
POINT a[1010];
inline bool vertical(POINT A, POINT B) {
return A.x==B.x;
}
inline void panta(POINT A, POINT B) {
if(vertical(A, B)) {
pan.push_back(INF);
return;
}
pan.push_back((B.y-A.y)/(B.x-A.x));
}
int main(void) {
freopen("trapez.in", "r", stdin);
freopen("trapez.out", "w", stdout);
int n, i, j, sum=0, nr=0;
double last, x, y;
scanf("%d", &n);
for(i=1; i<=n; i++) {
scanf("%lf%lf", &x, &y);
a[i].x = x;
a[i].y = y;
}
for(i=1; i<n; i++)
for(j=i+1; j<=n; j++)
panta(a[i], a[j]);
sort(pan.begin(), pan.end());
last = pan[0];
nr = 1;
for(i=1; i<pan.size() ;i++) {
if(last==pan[i])
nr++;
else {
if(nr>1)
sum+=(nr*(nr-1)/2);
nr=1;
last=pan[i];
}
}
printf("%d\n", sum);
return 0;
}