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 Rust (judge verdict: Accepted)

extern crate core;

use std::fmt;
use std::cmp::{Ordering, min, max};
use std::fmt::{Display, Error, Formatter, Binary};
use std::f32::MAX;
use std::ops::{Add, Sub, Mul, Div, Neg, Index, IndexMut};
use std::collections::{BTreeMap, VecDeque, BinaryHeap, BTreeSet};

fn show<T: Display>(vec: &Vec<T>) {
    if vec.is_empty() {
        println!("[]");
    }else {
        print!("[{}", vec[0]);
        for i in 1 .. vec.len() {
            print!(", {}", vec[i]);
        }
        println!("]");
    }
}
fn show2<T: Display>(vec: &Vec<Vec<T>>) {
    if vec.is_empty() {
        println!("[]");
    }else {
        for l in vec {
            show(l);
        }
    }
}
macro_rules! read_line{
    () => {{
        let mut line = String::new();
        std::io::stdin().read_line(&mut line).ok();
        line
    }};
    (delimiter: ' ') => {
        read_line!().split_whitespace().map(|x|x.to_string()).collect::<Vec<_>>()
    };
    (delimiter: $p:expr) => {
        read_line!().split($p).map(|x|x.to_string()).collect::<Vec<_>>()
    };
    (' ') => {
        read_line!(delimiter: ' ')
    };
    ($delimiter:expr) => {
        read_line!(delimiter: $delimiter)
    };
    (' '; $ty:ty) => {
        read_line!().split_whitespace().map(|x|x.parse::<$ty>().ok().unwrap()).collect::<Vec<$ty>>()
    };
    ($delimiter:expr; $ty:ty) => {
        read_line!($delimiter).into_iter().map(|x|x.parse::<$ty>().ok().unwrap()).collect::<Vec<$ty>>()
    };
}
macro_rules! read_value{
    () => {
        read_line!().trim().parse().ok().unwrap()
    }
}
macro_rules! let_all {
    ($($n:ident:$t:ty),*) => {
        let line = read_line!(delimiter: ' ');
        let mut iter = line.iter();
        $(let $n:$t = iter.next().unwrap().parse().ok().unwrap();)*
    };
}
macro_rules! let_mut_all {
    ($($n:ident:$t:ty),*) => {
        let line = read_line!(delimiter: ' ');
        let mut iter = line.iter();
        $(let mut $n:$t = iter.next().unwrap().parse().ok().unwrap();)*
    };
}
const EPSILON: f64 = 0.000000001;
#[derive(Copy, Clone)]
struct Point {
    x: f64, y: f64
}
impl Point {
    fn distance(&self, other: &Self) -> f64 {
        ((self.x - other.x) * (self.x - other.x) + (self.y - other.y) * (self.y - other.y)).sqrt()
    }
}
impl Sub for Point {
    type Output = Vector;
    fn sub(self, rhs: Self) -> Self::Output {
        Vector{x: self.x - rhs.x, y: self.y - rhs.y}
    }
}
#[derive(Copy, Clone)]
struct Line {
    a: f64, b: f64, c: f64
}
impl Line {
    fn by_two_point(a: &Point, b: &Point) -> Line {
        Line{a: a.y - b.y, b: b.x - a.x, c: a.x * b.y - a.y * b.x}
    }
    fn is_parallel(&self, other: &Self) -> bool {
        (self.a * other.b - self.b * other.a).abs() < EPSILON
    }
    fn cross_point(&self, other: &Self) -> Option<Point> {
        let d = self.a * other.b - self.b * other.a;
        if d.abs() < EPSILON {
            None
        }else {
            Some(Point { x: (self.b * other.c - self.c * other.b) / d, y: (self.c * other.a - self.a * other.c) / d })
        }
    }
    fn cathetus(&self, point: &Point) -> Line {
        Line{a: self.b, b: -self.a, c: self.a * point.y - self.b * point.x}
    }
}
#[derive(Copy, Clone)]
struct Triangle {
    a: Point, b: Point, c: Point
}
impl Triangle {
    fn area(&self) -> f64 {
        let a = self.a.distance(&self.b);
        let b = self.b.distance(&self.c);
        let c = self.c.distance(&self.a);
        let s = (a + b + c) / 2_f64;
        (s * (s - a) * (s - b) * (s - c)).sqrt()
    }
    fn inner_circle_radius(&self) -> f64 {
        self.area() * 2_f64 / (self.a.distance(&self.b) + self.b.distance(&self.c) + self.c.distance(&self.a))
    }
    fn by_three_edges(a: &Edge, b: &Edge, c: &Edge) -> Option<Triangle> {
        if Triangle::can_make_triangle(a, b, c) {
            let la = Line::by_two_point(&a.from, &a.to);
            let lb = Line::by_two_point(&b.from, &b.to);
            let lc = Line::by_two_point(&c.from, &c.to);
            Some(Triangle{a: la.cross_point(&lb).unwrap(), b: lb.cross_point(&lc).unwrap(), c: lc.cross_point(&la).unwrap()})
        }else {
            None
        }
    }
    fn can_make_triangle(a: &Edge, b: &Edge, c: &Edge) -> bool {
        let va = a.to - a.from;
        let vb = b.to - b.from;
        let vc = c.to - c.from;
        va.cross(&vb) > 0_f64 && vb.cross(&vc) > 0_f64 && vc.cross(&va) > 0_f64
    }
}
#[derive(Copy, Clone)]
struct Edge {
    from: Point, to: Point
}
impl Edge {
    fn is_parallel(&self, other: &Self) -> bool {
        let Vector{x: ax, y: ay} = self.to - self.from;
        let Vector{x: bx, y: by} = other.to - other.from;
        (ax * by - ay * bx).abs() < EPSILON
    }
    fn distance_if_parallel(&self, other: &Self) -> Option<f64> {
        if self.is_parallel(other) {
            let sl = Line::by_two_point(&self.from, &self.to);
            let ol = Line::by_two_point(&other.from, &other.to);
            Some(Line::cathetus(&sl, &self.from).cross_point(&ol).unwrap().distance(&self.from))
        }else {
            None
        }
    }
}
#[derive(Copy, Clone)]
struct Vector {
    x: f64, y: f64
}
impl Vector {
    fn cross(&self, other: &Self) -> f64 {
        self.x * other.y - self.y * other.x
    }
}
fn main() {
    loop {
        let_all!(n: usize);
        if n == 0 {
            return
        }
        let mut points = Vec::with_capacity(n);
        for _ in 0 .. n {
            let_all!(x: f64, y: f64);
            points.push(Point{x: x, y: y});
        }
        let mut edges = Vec::with_capacity(n);
        edges.push(Edge{from: points[n - 1], to: points[0]});
        for i in 1 .. n {
            edges.push(Edge{from: points[i - 1], to: points[i]});
        }
        let mut min_r = std::f64::MAX;
        for i in 0 .. n {
            for j in 0 .. i {
                if let Some(d) = edges[i].distance_if_parallel(&edges[j]) {
                    if min_r > d / 2_f64 {
                        min_r = d/ 2_f64;
                    }
                }else {
                    for k in 0..j {
                        if let Some(t) = Triangle::by_three_edges(&edges[k], &edges[j], &edges[i]) {
                            let r = t.inner_circle_radius();
                            if min_r > r {
                                min_r = r;
                            }
                        }
                    }
                }
            }
        }
        println!("{:.*}", 10, min_r);
    }
}