Pagini recente » Cod sursa (job #1654259) | Cod sursa (job #370318) | Cod sursa (job #1715497) | Cod sursa (job #880304) | Cod sursa (job #3234372)
#include <iostream>
#include <fstream>
#include <set>
#include <math.h>
using namespace std;
ifstream f ("date.in");
ofstream g ("date.out");
const int eps = 1e5;
struct punct {
int x, y;
bool operator < (const punct& a) const {
if(x != a.x)
return x < a.x;
if(x != a.y)
return y < a.y;
return 0;
}
};
inline int rnd(float x) {
return round(x * eps);
}
set<punct> puncte;
bool exptr(punct a, punct b) {
int cy = b.x - a.x, cx = a.y - b.y;
return (puncte.find({a.x + cx, a.x + cy}) != puncte.end() && puncte.find({b.y + cx, b.y + cy}) != puncte.end());
}
int main() {
int n, rez = 0;
float a, b;
f >> n;
for(int i = 0; i < n; i++) {
f >> a >> b;
puncte.insert({rnd(a), rnd(b)});
}
for(punct i : puncte)
for(punct j : puncte)
if(i.x != j.x && i.y != j.y)
rez += exptr(i, j);
g << rez / 4;
return 0;
}