Pagini recente » Cod sursa (job #284737) | Cod sursa (job #2146685) | Cod sursa (job #2205639) | Cod sursa (job #2378192) | Cod sursa (job #2625882)
#include <bits/stdc++.h>
#include <fstream>
#define limit 1e-5
#define maxLength 1050
using namespace std;
fstream fin("patrate3.in", ios::in);
fstream fout("patrate3.out", ios::out);
struct point {
double x, y;
bool operator < (const point& other) const {
return (abs(x - other.x) < limit ? y < other.y - limit : x < other.x - limit);
}
};
point pointsVec[1100];
set <point> s;
bool check(int a, int b) {
double xm = (pointsVec[a].x + pointsVec[b].x) / 2;
double ym = (pointsVec[a].y + pointsVec[b].y) / 2;
double delta_y = abs(ym - pointsVec[a].y);
double delta_x = abs(xm - pointsVec[a].x);
if (pointsVec[a].y < pointsVec[b].y)
delta_x *= -1;
point new_x, new_y;
new_x.x = xm - delta_y;
new_x.y = ym - delta_x;
new_y.x = xm + delta_y;
new_y.y = ym + delta_x;
if (s.find(new_x) != s.end() && s.find(new_y) != s.end())
return true;
return false;
}
int main() {
int n; fin >> n;
for (int i = 1; i <= n; i++)
{
fin >> pointsVec[i].x >> pointsVec[i].y;
s.insert(pointsVec[i]);
}
sort(pointsVec + 1, pointsVec + 1 + n);
int ans = 0;
for (int i = 1; i <= n; i++)
for (int j = i + 1; j <= n; j++)
ans += check(i, j);
fout << ans / 2;
}