Pagini recente » Cod sursa (job #1756335) | Cod sursa (job #2570021) | Cod sursa (job #1431850) | Cod sursa (job #2702117) | Cod sursa (job #2755660)
#include <fstream>
#include <cmath>
#include <set>
#define Nmax 1001
using namespace std;
set <pair <int, int> > s;
bool checkSquare(pair <int, int> x, pair <int, int> y){
int a, b;
a = x.first - y.first;
b = y.second - x.second;
if(s.find({x.first + b, x.second + a}) != s.end())
if(s.find({y.first + b, y.second + a}) != s.end())
return true;
return false;
}
int main()
{
ifstream f("patrate3.in");
ofstream g("patrate3.out");
pair <int, int> v[Nmax];
int n, ct = 0;
double c1, c2;
f >> n;
for(int i = 1; i <= n; ++i){
f >> c1 >> c2;
//cout << c1 << " " << c2 << '\n';
v[i].first = round(c1 * 10000);
v[i].second = round(c2 * 10000);
s.insert(v[i]);
}
for(int i = 1; i <= n; ++i){
for(int j = 1; j <= n; ++j){
if(i != j && checkSquare(v[i], v[j])){
++ct;
}
}
}
g << ct;
return 0;
}