Pagini recente » Cod sursa (job #1898311) | Cod sursa (job #1227340) | Cod sursa (job #1134434) | Cod sursa (job #2350021) | Cod sursa (job #2749136)
// Arbori_noduri_BST_Nebunii.cpp : This file contains the 'main' function. Program execution begins and ends there.
#include <bits/stdc++.h>
using namespace std;
ifstream fin("patrate3.in");
ofstream fout("patrate3.out");
set <pair<int, int>> chest;
pair<int, int> a,b;
int main()
{
int n;
int cnt = 0;
fin >> n;
vector<pair<int, int>> coords(n, { 0,0 });
for (int i = 0; i < n; i++) {
double x, y;
fin >> x >> y;
coords[i].first = round(x * 10000);
coords[i].second = round(y * 10000);
chest.insert(coords[i]);
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if (i != j) {
int x = coords[i].second - coords[j].second;
int y = coords[j].first - coords[i].first;
a = { coords[i].first + x, coords[i].second + y };
b = { coords[j].first + x,coords[j].second + y };
if (chest.find(a) != chest.end() && chest.find(b) != chest.end()) {
cnt++;
}
}
}
}
fout << cnt/4;
}