Pagini recente » Cod sursa (job #1950490) | Cod sursa (job #3232811) | Cod sursa (job #1474210) | Borderou de evaluare (job #2657902) | Cod sursa (job #3236761)
#include <bits/stdc++.h>
using namespace std;
ifstream f("patrate3.in");
ofstream g("patrate3.out");
set <pair<int, int>> set_puncte;
int main()
{
int n, nr = 0;
f >> n;
vector <pair<int, int>> puncte(n);
for (int i = 0; i < n; i++)
{
double x, y;
f >> x >> y;
x = round(x * 10000);
y = round(y * 10000);
puncte[i].first = x;
puncte[i].second = y;
set_puncte.insert(puncte[i]);
}
for (int i = 0; i < n-1; i++)
for (int j = i + 1; j < n; j++)
{
int mijx = (puncte[j].first + puncte[i].first)/2;
int mijy = (puncte[i].second + puncte[j].second)/2;
int dx = mijx - puncte[i].first;
int dy = mijy - puncte[i].second;
pair<int, int> d1 = { mijx - dy, mijy + dx };
pair<int, int> d2 = { mijx + dy, mijy - dx };
if (set_puncte.find(d1) != set_puncte.end() && set_puncte.find(d2) != set_puncte.end())
nr++;
}
g << nr / 2;
return 0;
}