Pagini recente » Cod sursa (job #421729) | Profil StarGold2 | Cod sursa (job #2373445) | Cod sursa (job #265539) | Cod sursa (job #1034182)
#include <fstream>
#include <algorithm>
using namespace std;
ifstream fin("trapez.in");
ofstream fout("trapez.out");
#define x first
#define y second
#define NMAX 1001
#define LL long long
#define PII pair <LL, LL>
int i, j, N, nr = 1;
int cnt;
int ANS;
PII P[NMAX];
PII Pante[NMAX * NMAX];
struct cmp {
bool operator() (const PII &a, const PII &b) const {
if (a.x * b.y < b.x * a.y) return 1;
return 0;
};
};
int main() {
fin >> N;
for (i = 1; i <= N; ++i)
fin >> P[i].x >> P[i].y;
for (i = 1; i <= N; ++i) {
for (j = i + 1; j <= N; ++j) {
Pante[++cnt].x = P[j].y - P[i].y;
Pante[cnt].y = P[j].x - P[i].x;
}
}
sort(Pante + 1, Pante + cnt + 1, cmp());
for (i = 2; i <= cnt; ++i) {
if (Pante[i].x * Pante[i - 1].y == Pante[i].y * Pante[i - 1].x) ++nr;
else {
ANS += (nr * (nr - 1) / 2);
nr = 1;
}
}
fout << ANS + (nr * (nr - 1) / 2) << '\n';
return 0;
}