Pagini recente » Cod sursa (job #916801) | Cod sursa (job #80303) | Cod sursa (job #1161835) | Cod sursa (job #1262229) | Cod sursa (job #976228)
Cod sursa(job #976228)
#include<cstdio>
#include<cmath>
#include<algorithm>
#define eps 1.e-6
using namespace std;
struct POINT
{
double x,y;
inline bool operator<(const POINT &other) const
{
if(fabs(x-other.x)<eps)
return y<other.y;
return x<other.x;
}
} A,B,p[1010];
int n;
bool searcH(const POINT &t)
{
int st,dr,med;
st=1;dr=n;
while(st<=dr)
{
med=(st+dr)/2;
if(fabs(p[med].x-t.x)<eps && fabs(p[med].y-t.y)<=eps)
return 1;
if(t<p[med])
dr=med-1;
else
st=med+1;
}
return 0;
}
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);
sort(p+1,p+n+1);
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(searcH(A) && searcH(B))
res++;
}
printf("%d\n",res/2);
return 0;
}