Pagini recente » Cod sursa (job #1058568) | Cod sursa (job #1825418) | Cod sursa (job #2041057) | Cod sursa (job #2974983) | Cod sursa (job #1166931)
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#define Nmax 1005
#define P 100021
#define eps 1.e-4
using namespace std;
struct pc
{
double x,y;
bool operator == (const pc A)
{
return (fabs(A.x-x)<eps && fabs(A.y-y)<eps);
}
};
pc v[Nmax];
vector <pc> L[P];
inline void AddHash(pc A)
{
int i=((int)A.x*100000LL+10000LL*P)%P;
L[i].push_back(A);
}
inline bool CautaHash(pc A)
{
int i=((int)A.x*100000LL+10000LL*P)%P;
vector <pc>::iterator it;
for(it=L[i].begin();it!=L[i].end();++it)
if(*it==A)
return true;
return false;
}
inline bool Cmp(const pc A, const pc B)
{
if(fabs(A.x-B.x)<eps)
return (B.y-A.y>=eps);
return (B.x-A.x>=eps);
}
int main()
{
int i,N,j,sol=0;
pc a,b;
freopen ("patrate3.in","r",stdin);
freopen ("patrate3.out","w",stdout);
scanf("%d", &N);
for(i=1;i<=N;++i)
{
scanf("%lf%lf", &v[i].x,&v[i].y);
AddHash(v[i]);
}
sort(v+1,v+N+1,Cmp);
for(i=1;i<N;++i)
for(j=i+1;j<=N;++j)
{
a.x=v[i].x+v[i].y-v[j].y;
a.y=v[i].y+v[j].x-v[i].x;
b.x=v[i].y+v[j].x-v[j].y;
b.y=v[j].x+v[j].y-v[i].x;
if(CautaHash(a) && CautaHash(b))
++sol;
}
printf("%d\n", sol/2);
}