#include"string.h" #include"stdio.h" #include"iostream" #include"queue" #include"stack" #define M 10009 #define N 100009 #include"stdlib.h" #include"math.h" #define inf 99999999 #define eps 1e-8 #define PI acos(-1.0) using namespace std; struct node { double x,y,dis; }p[6],q[100]; double max(double x,double y) { return x>y?x:y; } double min(double x,double y) { return x<y?x:y; } double len(node a,node b) { return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y)); } double fun(node q) { double sum=0; for(int i=0;i<4;i++) sum+=len(q,p[i]); return sum; } int main() { int i,j; while(scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&p[0].x,&p[0].y,&p[1].x,&p[1].y,&p[2].x,&p[2].y,&p[3].x,&p[3].y)!=-1) { int flag=0; for(i=0;i<4;i++) if(fabs(p[i].x+1)<eps&&fabs(p[i].y+1)<eps) flag++; if(flag==4) break; node a,b; a.x=a.y=inf; b.x=b.y=-inf; for(i=0;i<4;i++) { a.x=min(a.x,p[i].x); a.y=min(a.y,p[i].y); b.x=max(b.x,p[i].x); b.y=max(b.y,p[i].y); } for(i=1;i<=20;i++)//枚举的时候尽量在内部枚举这些点 { q[i].x=(rand()%1000+10)/1000.0*(b.x-a.x)+a.x;// q[i].y=(rand()%1000+10)/1000.0*(b.y-a.y)+a.y;// q[i].dis=fun(q[i]); } double temp=len(a,b); while(temp>eps) { for(i=1;i<=20;i++) { for(j=0;j<25;j++) { double rad=(rand()%1000+10)/1000.0*PI*10; node cur; cur.x=temp*cos(rad); cur.y=temp*sin(rad); if(cur.x<a.x||cur.y<a.y||cur.x>b.x||cur.x>b.y)continue; cur.dis=fun(cur); if(cur.dis<q[i].dis) q[i]=cur; } } temp*=0.981; } double mini=q[1].dis; for(i=2;i<=20;i++) { if(mini>q[i].dis) mini=q[i].dis; } printf("%.4lf ",mini); } }