Pagini recente » Cod sursa (job #3038084) | Cod sursa (job #621288) | Cod sursa (job #2128059) | Cod sursa (job #2641241) | Cod sursa (job #3235730)
#include <iostream>
#include <fstream>
#include <set>
#include <cmath>
using namespace std;
const double EPS=1e-5;
ifstream f("patrate3.in");
ofstream g("patrate3.out");
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 solve()
{
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++;
}
g<<nrp/2;
}
int main()
{
f>>N;
for(int i=1;i<=N;i++)
{
f>>P[i].x>>P[i].y;
S.insert(P[i]);
}
solve();
f.close();
g.close();
return 0;
}