Pagini recente » Cod sursa (job #2625813) | Cod sursa (job #1226711) | Cod sursa (job #2309118) | Cod sursa (job #3279599) | Cod sursa (job #914227)
Cod sursa(job #914227)
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cmath>
#define eps 1.e-6
using namespace std;
struct POINT
{
double x,y;
};
POINT a[1100];
int n,i,j;
bool cmp(POINT const &x,POINT const &y)
{
if(fabs(x.x-y.x)<eps)
{
return x.y<y.y;
}
return x.x<y.x;
}
int bs(POINT X)
{
int st,dr,med;
st=1;
dr=n;
while(st<=dr)
{
med=((dr-st)>>1)+st;
if(fabs(a[med].x-X.x)<eps&&fabs(a[med].y-X.y)<eps)
{
return 1;
}
if(cmp(X,a[med]))
{
dr=med-1;
}
else
st=med+1;
}
return 0;
}
int main()
{
double v1,v2;
POINT A,B,X,Y;
int rez=0;
freopen("patrate3.in","r",stdin);
freopen("patrate3.out","w",stdout);
scanf("%d",&n);
for(i=1;i<=n;i++)
{
scanf("%lf%lf",&v1,&v2);
A.x=v1;
A.y=v2;
a[i]=A;
}
sort(a+1,a+n+1,cmp);
for(i=1;i<n;i++)
for(j=i+1;j<=n;j++)
{
A=a[i];
B=a[j];
X.x=A.x+A.y-B.y;
X.y=A.y+B.x-A.x;
Y.x=B.x+A.y-B.y;
Y.y=B.y+B.x-A.x;
if(bs(X)&&bs(Y))
{
rez++;
}
}
printf("%d",rez/2);
return 0;
}