program sq5
implicit none
integer seed,pa(2,10),flag,i,j,exp,big,cntng
real x(5),y(5),dx2,dy2,d,prob,xbig
data pa/1,2,1,3,1,4,1,5,2,3,2,4,2,5,3,4,3,5,4,5/
seed=time8()
call srand(seed)
1 print*,'exp?'
read*,exp
big=10**exp
xbig=big
if(exp.eq.0)stop
cntng=0
do i=1,big
do j=1,5
x(j)=10*rand()
y(j)=10*rand()
enddo
flag=0
do j=1,10
dx2=(x(pa(1,j))-x(pa(2,j)))**2
dy2=(y(pa(1,j))-y(pa(2,j)))**2
d=dx2+dy2
if(d.ge.64)then
if(flag.eq.1)go to 2
flag=1
endif
enddo
cntng=cntng+1
2 enddo
prob=(xbig-cntng)/xbig
print*,'exp prob ',exp,prob
go to 1
end