Pagini recente » Borderou de evaluare (job #1214133) | Borderou de evaluare (job #660260) | Borderou de evaluare (job #2225209) | Borderou de evaluare (job #2888077) | Cod sursa (job #3235309)
#include <iostream>
#include <fstream>
#include <set>
#include <math.h>
using namespace std;
ifstream f ("patrate3.in");
ofstream g ("patrate3.out");
const int eps = 10000;
struct Point
{
int x, y;
bool operator <(const Point& a) const
{
if(x != a.x)
return x < a.x;
if(x != a.y)
return y < a.y;
return 0;
}
};
int aprox(float x)
{
return round(x * eps);
}
set<Point> Points;
int main()
{
int n, cont = 0;
float x,y;
f >> n;
for(int i = 0; i < n; i++)
{
f >> x >> y;
Points.insert({aprox(x), aprox(y)});
}
for(Point i : Points)
for(Point j : Points)
if(i.x != j.x && i.y != j.y)
{
int cx = i.y - j.y;
int cy = j.x - i.x;
if(Points.find({i.x + cx, i.y + cy}) != Points.end() && Points.find({j.x + cx, j.y + cy}) != Points.end())
cont ++;
}
g << cont / 4;
return 0;
}