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++ (judge verdict: Wrong Answer)

#include<bits/stdc++.h>
using namespace std;
double x[200];
double y[200];
double EPS=1e-9;
struct L{ // ax+by+c=0
	double a,b,c;
	L(){}
	L(double A,double B,double C){
		a=A;
		b=B;
		c=C;
	}
};
struct P{
	double x,y;
	P(){}
	P(double X,double Y){
		x=X;
		y=Y;
	}
};
P inter(L s,L t){
	double det=s.a*t.b-s.b*t.a;
	if(abs(det)<EPS){
		return P(1000000009,1000000009);
	}
	return P((-t.b*s.c+s.b*t.c)/det,(-t.c*s.a+s.c*t.a)/det);
}
double dot(P a,P b){
	return a.x*b.x+a.y*b.y;
}
double cross(P a,P b){
	return a.x*b.y-a.y*b.x;
}
double norm(P a){
	return a.x*a.x+a.y*a.y;
}
int ccw(P a,P b,P c){
	b.x-=a.x;
	b.y-=a.y;
	c.x-=a.x;
	c.y-=a.y;
	if(cross(b,c)>0)return 1;
	if(cross(b,c)<0)return -1;
	if(dot(b,c)<0)return 2;
	if(norm(b)<norm(c))return -2;
	return 0;
}
double dist(L s,P t){ // 点と直線の距離
	return abs(s.a*t.x+s.b*t.y+s.c)/sqrt(s.a*s.a+s.b*s.b);
}
L convLine(P s,P t){ // (x1,y1),(x2,y2)を通る直線の型変換
	double theta=atan2(t.y-s.y,t.x-s.x);
	double A=sin(theta);
	double B=-cos(theta);
	double C=-(s.x*A+s.y*B);
	return L(A,B,C);
}
L lines[200];
L poly[100];
P point[100];
int main(){
	int a;
	while(scanf("%d",&a),a){
		for(int i=0;i<a;i++){
			scanf("%lf%lf",x+i,y+i);
		}
		x[a]=x[0];
		y[a]=y[0];
		for(int i=0;i<=a;i++)point[i]=P(x[i],y[i]);
		for(int i=0;i<a;i++){
			poly[i]=convLine(point[i],point[i+1]);
		//	printf("%f %f %f\n",poly[i].a,poly[i].b,poly[i].c);
		}
		double left=0;
		double right=10000;
		for(int i=0;i<50;i++){
			double M=(left+right)/2;
			for(int j=0;j<a;j++){
				lines[j*2]=L(poly[j].a,poly[j].b,poly[j].c-M);
				lines[j*2+1]=L(poly[j].a,poly[j].b,poly[j].c+M);
			}
			vector<P> points;
			for(int j=0;j<2*a;j++){
				for(int k=j+1;k<2*a;k++){
					P val=inter(lines[j],lines[k]);
					if(abs(val.x-1000000009)>EPS){
						points.push_back(val);
					}
				}
			}
			bool ok=false;
			for(int j=0;j<points.size();j++){
				bool OK=true;
				for(int k=0;k<a;k++){
					if(dist(poly[k],points[j])+EPS<M){
						OK=false;
						break;
					}
					if(ccw(point[k],points[j],point[k+1])!=-1)OK=false;
				}
				if(OK){
					ok=true;
					break;
				}
			}
			if(ok){
				left=M;
			}else right=M;
		}
		printf("%f\n",left);
	}
}