Pagini recente » Cod sursa (job #113091) | Cod sursa (job #2103147) | Istoria paginii runda/prega_oji2015_x_1 | Cod sursa (job #2846912) | Cod sursa (job #1153889)
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
const double eps=1.e-4;
struct point{
double x,y;
};
point v[1005];
bool cmp(point a,point b){
if(fabs(a.x-b.x)<eps) return a.y<b.y;
return a.x<b.x;
}
bool binar(int n,point x){
int st,dr,med;
st=1;
dr=n;
while(st<=dr){
med=st+(dr-st)/2;
if(fabs(v[med].x-x.x)<eps && fabs(v[med].y-x.y)<eps)
return 1;
else
if(cmp(x,v[med]))
dr=med-1;
else
st=med+1;
}
return 0;
}
bool solve(point aux,point auy,int n){
point a,b;
a.x=auy.x+aux.y-auy.y;
a.y=auy.y+auy.x-aux.x;
b.x=aux.x+aux.y-auy.y;
b.y=aux.y+auy.x-aux.x;
if(binar(n,a)&&binar(n,b))
return 1;
return 0;
}
int main(){
freopen("patrate3.in", "r", stdin);
freopen("patrate3.out", "w", stdout);
int n,i,j,sol=0;
double x,y;
scanf("%d",&n);
for(i=1;i<=n;++i){
scanf("%lf%lf",&x,&y);
v[i].x=x;
v[i].y=y;
}
sort(v+1,v+n+1,cmp);
for(i=1;i<n;++i){
for(j=i+1;j<=n;++j){
sol+=solve(v[i],v[j],n);
}
}
printf("%d\n",sol/2);
return 0;
}