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

import java.util.*;
import java.awt.geom.*;
public class Main {
	double EPS = 1.0e-08;

	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n == 0) break;
			Point2D [] inputlist = new Point2D[n];
			double startx = 0.0, starty = 0.0;
			for(int i = 0; i < n; i++){
				int x = sc.nextInt();
				int y = sc.nextInt();
				inputlist[i] = new Point2D.Double(x, y);
				startx += x;
				starty += y;
			}
			startx = startx / n;
			starty = starty / n;
			
			Line2D [] lineList = new Line2D[n];
			for(int i = 0; i < n; i++){
				lineList[i] = new Line2D.Double(inputlist[i], inputlist[(i+1) % n]);
			}
			
			Point2D startP = new Point2D.Double(startx, starty);
			double mindis = calcDis(startP, lineList);
			System.out.printf("%.6f\n",mindis);
		}
	}
	
	private double calcDis(Point2D startP, Line2D [] lineList){
		//double move = 0.5;
		double move = 0.95;
		double mindis = -1.0;
		int len = lineList.length;
		while(move > 1.0e-10){
			for(int i = 0; i < 5000;i++){
				mindis = -1;
				int minind = 0;
				for(int j = 0; j < len; j++){
					double nowdis = lineList[j].ptLineDist(startP);
					if(mindis < 0)mindis = nowdis;
					if(nowdis < mindis){
						mindis = nowdis;
						minind = j;
					}
				}
				int lineind = minind;
				Point2D forwardP = calcNearPoint(lineList[lineind], startP, mindis);
				Point2D forwardVec = getV(forwardP, startP);
				double nextx = startP.getX() - forwardVec.getX() * move;
				double nexty = startP.getY() - forwardVec.getY() * move;
				//startP = new Point2D.Double(nextx , nexty);
				startP.setLocation(nextx, nexty);
			}
			//move = move / 2;
			move = move / 1.25;
		}
		return mindis;
	}

	private Point2D calcNearPoint(Line2D line, Point2D p, double dis) {
		double disC = p.distance(line.getP1());
		double disB = Math.sqrt(disC * disC - dis * dis);
		double disD = line.getP1().distance(line.getP2());
		double rate = disB / disD;
		Point2D p2p1Vec = getV(line.getP2(), line.getP1());
		double x = p2p1Vec.getX() * rate + line.getP1().getX();
		double y = p2p1Vec.getY() * rate + line.getP1().getY();
		Point2D res = new Point2D.Double(x, y);
		return res;
	}

	private Point2D getV(Point2D p1, Point2D p2) {
		double x = p1.getX() - p2.getX();
		double y = p1.getY() - p2.getY();
		return new Point2D.Double(x, y);
	}

	public static void main(String[] args) {
		Main obj = new Main();
		obj.doit();
	}
}