Problem:
Problem I: Most Distant Point from the Sea

The main land of Japan called Honshu is an island surrounded by the sea. In such an island, it
is natural to ask a question: "Where is the most distant point from the sea?" The answer to
this question for Honshu was found in 1996. The most distant point is located in former Usuda
Town, Nagano Prefecture, whose distance from the sea is 114.86 km.

In this problem, you are asked to write a program which, given a map of an island, finds the
most distant point from the sea in the island, and reports its distance from the sea. In order to
simplify the problem, we only consider maps representable by convex polygons.

Input

The input consists of multiple datasets. Each dataset represents a map of an island, which is a convex polygon. The format of a dataset is as follows.

n
x1 y1
.
.
.
xn yn

Every input item in a dataset is a non-negative integer. Two input items in a line are separated by a space.

n in the first line is the number of vertices of the polygon, satisfying 3 ≤ n ≤ 100. Subsequent
n lines are the x- and y-coordinates of the n vertices. Line segments (xi, yi) - (xi+1, yi+1) (1 ≤ i ≤ n - 1) and the line segment (xn, yn) - (x1, y1) form the border of the polygon in counterclockwise order. That is, these line segments see the inside of the polygon in the left of their directions. All coordinate values are between 0 and 10000, inclusive.

You can assume that the polygon is simple, that is, its border never crosses or touches itself. As stated above, the given polygon is always a convex one.

The last dataset is followed by a line containing a single zero.

Output

For each dataset in the input, one line containing the distance of the most distant point from
the sea should be output. An output line should not contain extra characters such as spaces.

The answer should not have an error greater than 0.00001 (10-5 ). You may output any number
of digits after the decimal point, provided that the above accuracy condition is satisfied.

Sample Input

4
0 0
10000 0
10000 10000
0 10000
3
0 0
10000 0
7000 1000
6
0 40
100 20
250 40
250 70
100 90
0 70
3
0 0
10000 10000
5000 5001
0

Output for the Sample Input

5000.000000
494.233641
34.542948
0.353553

Solution in C++11 (judge verdict: Accepted)

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair<int,int> PI;
const double EPS=1e-6;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define F first
#define S second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SZ(a) (int)((a).size())
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) a.rbegin(),a.rend()
#define FLL(a,b) memset((a),b,sizeof(a))
#define CLR(a) FLL(a,0)
#define declare(a,it) __typeof(a) it=(a)
#define FOR(it,a) for(declare(a.begin(),it);it!=a.end();++it)
#define FORR(it,a) for(declare(a.rbegin(),it);it!=a.rend();++it)
template<class T,class U> ostream& operator<< (ostream& o, const pair<T,U>& v){return o << "(" << v.F << ", " << v.S << ")";}
template<class T> ostream& operator<< (ostream& o, const vector<T>& v){o << "{";rep(i,SZ(v)) o << (i?", ":"") << v[i];return o << "}";}
int dx[]={0,1,0,-1,1,1,-1,-1};
int dy[]={1,0,-1,0,-1,1,1,-1};
int s2i(string& a){stringstream ss(a);int r;ss>>r;return r;}
int geti(){int n;scanf("%d", &n);return n;}


typedef double FP;

typedef complex<FP> pt;
typedef pt P;
typedef pair<pt,pt> line;
namespace std{
  bool operator<(const P&a,const P&b){
    if(abs(a.real()-b.real())>EPS)
      return a.real()<b.real();
    return a.imag()<b.imag();
  }
}
FP dot(P a,P b){return real(conj(a)*b);}
FP crs(P a,P b){return imag(conj(a)*b);}
P ortho(P a){return P(imag(a),-real(a));}
P ortho(line a){return ortho(a.second-a.first);}
P crspt(P a,P b,P c,P d){b-=a,d-=c;return a+b*crs(d,c-a)/crs(d,b);}
P crspt(line a,line b){return crspt(a.first,a.second,b.first,b.second);}
bool onl(P a1,P a2,P b){return abs(b-a1)+abs(b-a2)<abs(a1-a2)+EPS;}
bool onl(line a,P b){return onl(a.first,a.second,b);}
bool iscrs(line a,line b){P c=crspt(a,b);return onl(a,c)&&onl(b,c);}
line mkl(P a,P v){return line(a,a+v);}
FP lpdist(line a,P b){return abs(b-crspt(a,mkl(b,ortho(a))));}

void check(P a){

  // assert(!isnan(a.real()));
  // assert(!isnan(a.imag()));
}

void check(line a){
  check(a.first);
  check(a.second);  
}

bool para(line a, line b){
  P av = a.first - a.second;
  P bv = b.first - b.second;
  return abs(dot(av/abs(av),bv/abs(bv))) > 1 - 1e-9;
}

double tri(P a, P b, P c){
  a -= c;
  b -= c;
  return abs(crs(a,b));
}

line midline(line a,line b){
  if(!para(a,b)){
    P av = a.second - a.first;
    P bv = b.second - b.first;
    av /= abs(av);
    bv /= abs(bv);
    auto ret = line(crspt(a,b),crspt(a,b)+av+bv);
    check(ret);
    return ret;
  }
  P st =(a.first+b.first)/2.;
  auto ret = line(st, st + a.second - a.first);
  check(ret);
  return ret;
}

int main(int argc, char *argv[]){
  int n;
  while(cin >> n && n){
    int x[n], y[n];
    for(int i = 0; i < n; ++i)
      cin >> x[i] >> y[i];
    double cx = accumulate(x,x+n,0.)/n;
    double cy = accumulate(y,y+n,0.)/n;
      
    double ans = 0;
    for(int i = 0; i < n; ++i){
      
      for(int j = 0; j < i; ++j){
        if(i == j) continue;
        double r = 10000000000;
        for(int k = 0; k < n; ++k){
          if(i == k || j == k) continue;
          line il = line(P(x[i],y[i]), P(x[(i+1)%n],y[(i+1)%n]));
          line jl = line(P(x[(j+1)%n],y[(j+1)%n]), P(x[j],y[j]));
          line kl = line(P(x[(k+1)%n],y[(k+1)%n]), P(x[k],y[k]));
          line ij = midline(il, jl);
          line ik = midline(il, kl);
          // if(!iscrs(ij, ik)){
          //   cout << ij << "  " << ik << endl;
          //   continue;
          // }
          P ce = crspt(ij,ik);
          if(!isnormal(ce.real()) || !isnormal(ce.imag())){
            //cout << ce << endl;
            continue;
          }
          double me = 0;
          double me2 = 0;
          for(int ii = 0; ii < n; ++ii){
            me += tri(P(x[ii],y[ii]), P(x[(ii+1)%n],y[(ii+1)%n]),ce);
            me2 += tri(P(x[ii],y[ii]), P(x[(ii+1)%n],y[(ii+1)%n]),P(cx,cy));
          }
          
          if(abs(me-me2)/max(me,me2) > EPS){
            //cout << me << " " << me2 << endl;
            continue;
          }
          
          double tr = 10000000000;
          for(int ii = 0; ii < n; ++ii){
            line l(P(x[ii],y[ii]),P(x[(ii+1)%n],y[(ii+1)%n]));
            tr = min(tr, lpdist(l,ce));
          }
          ans = max(tr, ans);
          //cout << ce << endl;
          double cr = lpdist(il,ce);
          r = min(r, cr);
        }
        //ans = max(r, ans);
      }
    }
    printf("%.8f\n", ans);
  }
}