Pagini recente » Cod sursa (job #606788) | Cod sursa (job #3305358) | Cod sursa (job #3326330) | Cod sursa (job #3337935) | Cod sursa (job #3309404)
#include <fstream>
#include <cmath>
#include <set>
using namespace std;
const double EPS = 1e-5;
const int NMAX = 1001;
int n, cnt;
struct punct
{
double x, y;
bool operator<(const punct &B)const
{
if(abs(x - B.x) > EPS)
return x < B.x;
//
if(abs(y - B.y) > EPS)
return y < B.y;
return 0;
}
} pc[NMAX];
set<punct> S;
ifstream f("patrate3.in");
ofstream g("patrate3.out");
int main()
{
int i, j;
f >> n;
for(i = 1; i <= n; i++)
f >> pc[i].x >> pc[i].y, S.insert(pc[i]);
//
punct mij, c, d;
for(i = 1; i < n; i++)
for(j = i + 1; j <= n; j++)
{
mij.x = (pc[i].x + pc[j].x) / 2;
mij.y = (pc[i].y + pc[j].y) / 2;
//
c.x = mij.x - pc[j].y + mij.y;
c.y = mij.y + pc[j].x - mij.x ;
//
d.x = mij.x + pc[j].y - mij.y;
d.y = mij.y - pc[j].x + mij.x;
//
if(S.find(c) != S.end() && S.find(d) != S.end())
cnt++;
}
g << cnt / 2;
f.close();
g.close();
return 0;
}