Pagini recente » Cod sursa (job #2735382) | Cod sursa (job #1669406) | Cod sursa (job #2374805) | Cod sursa (job #1537437) | Cod sursa (job #611112)
Cod sursa(job #611112)
#include <stdio.h>
#include <math.h>
#include <algorithm>
#define eps 1
#define INF 10E20
//using namespace std;
class POINT {
public:
double x, y;
void read(char type = 'i') {//i = long, d = double
long ax, ay;
double bx, by;
if(type == 'i') {
scanf("%ld%ld", &ax, &ay);
x = ax;
y = ay;
}
else {
scanf("%lf%lf", &bx, &by);
x = bx;
y = by;
}
}
double panta(POINT &other) {
if(other.x == x)
return INF;
else return (other.y - y) / (other.x - x);
}
};
long n, nm;
double pante[500000], p, lp;
POINT P[1001];
int cmp(double x, double y) {
if(x > y)
return 0;
else return 1;
}
int main() {
long i, j, i1, k = 0, d, cs;
freopen("trapez.in", "r", stdin);
freopen("trapez.out", "w", stdout);
scanf("%ld", &n);
for(i = 1; i <= n; i++)
P[i].read('i');
for(i = 1; i <= n; i++)
for(j = i + 1; j <= n; j++) {
p = P[i].panta(P[j]);
pante[++nm] = p;
}
std::sort(pante[1], pante[nm + 1]);
cs = 1;
lp = pante[i];
for(i = 2; i <= nm + 1; i++) {
if(lp == pante[i])
cs++;
else {
lp = pante[i];
k += (cs * (cs - 1)) / 2;
cs = 1;
}
}
printf("%ld", k);
return 0;
}