Pagini recente » Cod sursa (job #2868241) | Cod sursa (job #960726) | Cod sursa (job #773173) | Cod sursa (job #1323513) | Cod sursa (job #2749189)
#include <iostream>
#include <fstream>
#include <set>
#include <algorithm>
#include <math.h>
#include <vector>
using namespace std;
ifstream fin("patrate3.in");
ofstream fout("patrate3.out");
set <pair<int, int>> set_puncte;
int main()
{
int n, nr = 0;
fin >> n;
vector <pair<int, int>> puncte(n);
for (int i = 0; i < n; i++)
{
double x, y;
fin >> 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++;
}
fout << nr / 2;
return 0;
}