Pagini recente » Cod sursa (job #1294055) | Cod sursa (job #484001) | Cod sursa (job #1041132) | Cod sursa (job #2278898) | Cod sursa (job #1166918)
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#define Nmax 1005
#define P 666013
#define eps 0.00001
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*10000LL+(int)A.y*10000LL+1000LL*P)%P;
L[i].push_back(A);
}
inline bool CautaHash(pc A)
{
int i=((int)A.x*10000LL+(int)A.y*10000LL+1000LL*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 A.y<B.y;
return A.x<B.x;
}
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);
}