Pagini recente » Cod sursa (job #230251) | Cod sursa (job #828793) | Cod sursa (job #2179456) | Cod sursa (job #1871389) | Cod sursa (job #3331569)
#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;
ifstream fin("patrate3.in");
ofstream fout("patrate3.out");
const int NMAX = 1000;
int n, answer;
ld x[NMAX + 1], y[NMAX + 1];
map<pair<ld, ld>, int> mp;
ld get_slope(ld x1, ld y1, ld x2, ld y2) {
return (y2 - y1) / (x2 - x1);
}
ld get_distance(ld x1, ld y1, ld x2, ld y2) {
return (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1);
}
int main()
{
fin >> n;
for(int i = 1; i <= n; i++) {
fin >> x[i] >> y[i];
}
for(int i = 1; i <= n; i++) {
for(int j = i + 1; j <= n; j++) {
ld slope = get_slope(x[i], y[i], x[j], y[j]);
ld dist = get_distance(x[i], y[i], x[j], y[j]);
mp[{slope, dist}]++;
}
}
for(int i = 1; i <= n; i++) {
for(int j = i + 1; j <= n; j++) {
ld slope = get_slope(x[i], y[i], x[j], y[j]);
ld dist = get_distance(x[i], y[i], x[j], y[j]);
answer += (mp[{slope, dist}] - 1);
}
}
fout << answer << '\n';
return 0;
}