Pagini recente » Cod sursa (job #909375) | Cod sursa (job #840674) | Cod sursa (job #2122559) | Cod sursa (job #460240) | Cod sursa (job #2916319)
#include <fstream>
#include <algorithm>
using namespace std;
#define N 1000
#define NM 499500
typedef long double ld;
ifstream f("trapez.in");
ofstream g("trapez.out");
struct point {
ld x, y;
bool operator == (const point& a) const {
return y / x == a.y / a.x ;
}
};
point v[N], m[NM];
// a.x b.x
// --- < ---
// a.y b.y
bool cmp(point a, point b) {
return a.x * b.y < a.y * b.x;
}
point slope(point a, point b) {
return {b.x - a.x, b.y - a.y};
}
int main() {
int n, idx = 0;
f >> n;
for (int i = 0; i < n; i++) {
f >> v[i].x >> v[i].y;
for (int j = 0; j < i; j++)
m[idx++] = slope(v[i], v[j]);
}
sort(m, m + idx, cmp);
int s = 0, cnt = 1;
for (int i = 0 ; i < idx; i++)
if (m[i] == m[i + 1])
cnt++;
else {
s += cnt * (cnt - 1);
cnt = 1;
}
g << (s >> 1);
return 0;
}