Pagini recente » Cod sursa (job #831965) | Cod sursa (job #1927912) | Cod sursa (job #2645887) | Cod sursa (job #2973625) | Cod sursa (job #3262195)
#include <fstream>
#include <set>
using namespace std;
ifstream fin("patrate3.in");
ofstream fout("patrate3.out");
const double EPS = 1e-5;
struct Punct
{
double x, y;
Punct(double x = 0.0, double y = 0.0): x(x), y(y) {}
bool operator<(const Punct &A) const
{
if(abs(x - A.x) > EPS) return x < A.x;
if(abs(y - A.y) > EPS) return y < A.y;
return 0;
}
};
int n;
Punct p[1001];
set<Punct> s;
void solutie()
{
Punct m, a, b;
int nrp = 0;
for(int i = 1; i < n; ++i)
for(int j = i + 1; j <= n; ++j)
{
m.x = (p[i].x + p[j].x) / 2;
m.y = (p[i].y + p[j].y) / 2;
a.x = m.x - p[j].y + m.y;
a.y = m.y + p[j].x - m.x;
b.x = m.x + p[j].y - m.y;
b.y = m.y - p[j].x + m.x;
if(s.find(a) != s.end() && s.find(b) != s.end()) ++nrp;
}
fout << nrp / 2;
}
int main()
{
fin >> n;
for(int i = 1; i <= n; ++i)
{
fin >> p[i].x >> p[i].y;
s.insert(p[i]);
}
solutie();
return 0;
}