Pagini recente » Cod sursa (job #680790) | Cod sursa (job #1286878) | Cod sursa (job #2888983) | Cod sursa (job #2958787) | Cod sursa (job #2749185)
#include <iostream>
#include <fstream>
#include <set>
#include <algorithm>
#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 dif1 = puncte[j].first - puncte[i].first;
int dif2 = puncte[i].second - puncte[j].second;
pair<int, int> pct1, pct2;
pct1 = { puncte[i].first + dif2, puncte[i].second + dif1 };
pct2 = { puncte[j].first + dif2, puncte[j].second + dif1 };
if (set_puncte.find(pct1) != set_puncte.end() && set_puncte.find(pct2) != set_puncte.end())
nr++;
}
fout << nr / 2;
return 0;
}