Pagini recente » Cod sursa (job #695234) | Cod sursa (job #500801) | Cod sursa (job #2522393) | Cod sursa (job #14907) | Cod sursa (job #3164316)
#include <bits/stdc++.h>
using namespace std;
int n, ans;
vector<pair<double, double>> v;
map<pair<double, double>, bool> m;
double calcDist(pair<double, double> x, pair<double, double> y) {
return sqrt((x.first - y.first) * (x.first - y.first) + (x.second - y.second) * (x.second - y.second));
}
double round3(double x) {
return (int) x * 1000 / 1000.0;
}
int main() {
cin >> n;
for (int i = 1; i <= n; ++i) {
double x, y;
cin >> x >> y;
x = round3(x);
y = round3(y);
v.push_back({x, y});
m[{x, y}] = true;
}
sort(v.begin(), v.end());
for (int i = 0; i < v.size(); ++i) {
for (int j = i + 1; j < v.size(); ++j) {
double a = calcDist(v[i], v[j]) / 2;
double b = calcDist(v[i], v[j]) * sqrt(3) / 2;
if (m.find({round3(v[i].first + a), round3(v[i].second + b)}) != m.end()) {
++ans;
}
if (m.find({round3(-(v[i].first + a)), round3(-(v[i].second + b))}) != m.end()) {
++ans;
}
}
}
cout << ans;
}