1 1 -1 1 1 0 -1 1 0 0 2 -1 1 1 0 -1 1 0 0 0
1.75 2.00
#include<iostream> #include<cstring> #include<cstdio> #include<cmath> #include<vector> #include<deque> #include<algorithm> using namespace std; const int N=122; const double eps=1e-9; const double pi=acos(-1.0); int dcmp(double a){if(abs(a)<eps)return 0;return a>0?1:-1;} #define sig dcmp double sqr(double a){return a*a;} struct point { double x,y; point(){} point(double _x,double _y){x=_x,y=_y;} void input(){cin>>x>>y;} double norm(){return sqrt(x*x+y*y);} point rot90(){return point(-y,x);} double abs(){return hypot(x,y);} bool operator==(point p){return !sig(x-p.x)&&!sig(y-p.y);} bool operator<(point p)const{ if(!sig(y-p.y))return x<p.x; return y<p.y; } }; double dist(point a,point b){return sqrt(sqr(a.x-b.x)+sqr(a.y-b.y));} point operator+(point a,point b){return point(a.x+b.x,a.y+b.y);} point operator-(point a,point b){return point(a.x-b.x,a.y-b.y);} point operator*(point a,double b){return point(a.x*b,a.y*b);} point operator*(double b,point a){return point(a.x*b,a.y*b);} point operator/(point a,double b){return point(a.x/b,a.y/b);} double det(point a,point b){return a.x*b.y-a.y*b.x;} #define cross det double dot(point a,point b){return a.x*b.x+a.y*b.y;} double dis(point p,point s,point t) { if(dcmp(dot(p-s,t-s))<0)return (p-s).norm(); if(dcmp(dot(p-t,s-t))<0)return (p-t).norm(); return fabs(det(s-p,t-p))/dist(s,t); } point st,C,p[5];double r; point get(point p,double ang) { return point(p.x+r*cos(ang),p.y+r*sin(ang)); } double len(point a) { double ans=1e8; for(int i=0;i<4;i++) { ans=min(ans,dis(a,p[i],p[i+1])); } return ans+dist(a,st); } void solve() { double ans=1e8; //for(double ang=0;ang<2*pi;ang+=0.001) double l=0,r=2*pi,s1,s2; while(r-l>1e-3) { double a1=l+(r-l)/3; double a2=r-(r-l)/3; point mid=get(C,a1); s1=len(mid);//ans=min(ans,len(mid)); mid=get(C,a2); s2=len(mid); if(s1>s2)l=a1; else r=a2; } printf("%.2f\n",s1); } int main() { while(scanf("%lf%lf",&st.x,&st.y)!=EOF) { if(st.x==0&&st.y==0)break; C.input();cin>>r; p[0].input();p[2].input();p[4]=p[0]; p[1]=point(p[0].x,p[2].y); p[3]=point(p[2].x,p[0].y); solve(); } }