Pagini recente » Cod sursa (job #663071) | Cod sursa (job #1242784) | Cod sursa (job #1838876) | Cod sursa (job #1828414) | Cod sursa (job #2755879)
#include <iostream>
#include <fstream>
#include <set>
#include <math.h>
#include <utility>
int main()
{
std::ifstream f("patrate3.in");
std::ofstream g("patrate3.out");
std::set<std::pair<int, int>> Hash_Puncte;
short N;
int Rezultat = 0;
f >> N;
for(float px, py, i = 0; i < N; ++i)
{
f >> px >> py;
Hash_Puncte.insert(std::make_pair(round(px * 10000), round(py * 10000)));
}
for(auto it1 = Hash_Puncte.begin(); it1 != Hash_Puncte.end(); ++it1)
for(auto it2 = Hash_Puncte.begin(); it2 != Hash_Puncte.end(); ++it2)
if(it1 != it2)
{
float px3 = it1->second - it2->second + it2->first;
float px4 = it1->second - it2->second + it1->first;
float py3 = it2->first - it1->first + it2->second;
float py4 = it2->first - it1->first + it1->second;
if(Hash_Puncte.find(std::make_pair(px3, py3)) != Hash_Puncte.end() &&
Hash_Puncte.find(std::make_pair(px4, py4)) != Hash_Puncte.end())
++Rezultat;
}
g << Rezultat / 4;
return 0;
}