Pagini recente » Cod sursa (job #2755752) | lista-lui-wefgef/clasament | Cod sursa (job #2950016) | Cod sursa (job #2723985) | Cod sursa (job #2755668)
#include <fstream>
#include <cmath>
#include <set>
#define Nmax 1001
using namespace std;
bool checkSquare(pair <int, int> x, pair <int, int> y, set <pair <int, int> >& k){
int a, b;
a = x.first - y.first;
b = y.second - x.second;
if(k.find({x.first + b, x.second + a}) != k.end())
if(k.find({y.first + b, y.second + a}) != k.end())
return true;
return false;
}
int main()
{
ifstream f("patrate3.in");
ofstream g("patrate3.out");
set <pair <int, int> > s;
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], s)){
++ct;
}
}
}
g << (ct >> 2);
return 0;
}