Pagini recente » Cod sursa (job #976371) | Cod sursa (job #1211210) | Monitorul de evaluare | Cod sursa (job #1845411) | Cod sursa (job #976226)
Cod sursa(job #976226)
#include<cstdio>
#include<cmath>
#include<unordered_set>
#define eps 1.e-6
using namespace std;
struct POINT
{
double x,y;
inline bool operator==(const POINT &other) const
{
return fabs(x-other.x)<eps && fabs(y-other.y)<eps;
}
} A,B,p[1010];
class HASH_POINT
{
public: inline int operator()(const POINT &x) const
{
return int((x.x*1000)+x.y);
}
};
unordered_set<POINT,HASH_POINT> q;
int n;
int main()
{
freopen("patrate3.in","r",stdin);
freopen("patrate3.out","w",stdout);
int res=0;
scanf("%d",&n);
for(int i=1;i<=n;i++)
scanf("%lf%lf",&p[i].x,&p[i].y),
q.insert(p[i]);
for(int i=1;i<=n;i++)
for(int j=i+1;j<=n ;j++)
{
A.x=p[i].x+p[i].y-p[j].y;
A.y=p[i].y+p[j].x-p[i].x;
B.x=p[i].y+p[j].x-p[j].y;
B.y=p[j].x+p[j].y-p[i].x;
if(q.find(A)!=q.end() && q.find(B)!=q.end())
res++;
}
printf("%d\n",res/2);
return 0;
}