#include #include #include #include #include #include using namespace std; const int M=15; const double inf=1e250; struct point { double x,y; bool operator < (const point a)const { if(y==a.y) return x0 && cross(stac[top],p[i],stac[top-1])<=0) top--; stac[++top]=p[i]; } int temp=top; for(int i=n-2;i>=0;i--) { while(top>temp && cross(stac[top],p[i],stac[top-1])<=0) top--; stac[++top]=p[i]; } } int main() { 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)==8) { if(p[0].x==-1 && p[0].y==-1 && p[1].x==-1 && p[1].y==-1 && p[2].x==-1 && p[2].y==-1 && p[3].x==-1 && p[3].y==-1) break; n=4; covex_hull(); double ans; if(top==4) { ans=dis(stac[0],stac[2])+dis(stac[1],stac[3]); } else { ans=inf; ans=min(ans,dis(p[0],p[1])+dis(p[0],p[2])+dis(p[0],p[3])); ans=min(ans,dis(p[1],p[0])+dis(p[1],p[2])+dis(p[1],p[3])); ans=min(ans,dis(p[2],p[1])+dis(p[2],p[0])+dis(p[2],p[3])); ans=min(ans,dis(p[3],p[1])+dis(p[3],p[2])+dis(p[3],p[0])); } printf("%.4lf\n",ans); } return 0; }