Problem:
Score : 500 points

Problem Statement

#nck {
width: 30px;
height: auto;
}

Snuke received a triangle as a birthday present.
The coordinates of the three vertices were (x_1, y_1), (x_2, y_2), and (x_3, y_3).

He wants to draw two circles with the same radius inside the triangle such that the two circles do not overlap (but they may touch).
Compute the maximum possible radius of the circles.

Constraints

0 ≤ x_i, y_i ≤ 1000

The coordinates are integers.

The three points are not on the same line.

Input

The input is given from Standard Input in the following format:

x_1 y_1
x_2 y_2
x_3 y_3

Output

Print the maximum possible radius of the circles.
The absolute error or the relative error must be at most 10^{-9}.

Sample Input 1

0 0
1 1
2 0

Sample Output 1

0.292893218813

Sample Input 2

3 1
1 5
4 9

Sample Output 2

0.889055514217

Solution in Rust (1.15.1) (judge verdict: Accepted)

#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::iter::FromIterator;
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};
mod util {
    use std::io::stdin;
    use std::str::FromStr;
    use std::fmt::Debug;
    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }
    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
}
#[allow(unused_macros)]
macro_rules ! get { ( $ t : ty ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; line . trim ( ) . parse ::<$ t > ( ) . unwrap ( ) } } ; ( $ ( $ t : ty ) ,* ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; let mut iter = line . split_whitespace ( ) ; ( $ ( iter . next ( ) . unwrap ( ) . parse ::<$ t > ( ) . unwrap ( ) , ) * ) } } ; ( $ t : ty ; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ ( $ t : ty ) ,*; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( $ ( $ t ) ,* ) ) . collect ::< Vec < _ >> ( ) } ; ( $ t : ty ;; ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; line . split_whitespace ( ) . map ( | t | t . parse ::<$ t > ( ) . unwrap ( ) ) . collect ::< Vec < _ >> ( ) } } ; }
#[allow(unused_macros)]
macro_rules ! debug { ( $ ( $ a : expr ) ,* ) => { println ! ( concat ! ( $ ( stringify ! ( $ a ) , " = {:?}, " ) ,* ) , $ ( $ a ) ,* ) ; } }

fn dist((x1, y1): (f64, f64), (x2, y2): (f64, f64)) -> f64 {
    f64::sqrt((x1 - x2).powi(2) + (y1 - y2).powi(2))
}

fn angle((x1, y1): (f64, f64), (x2, y2): (f64, f64), (x3, y3): (f64, f64)) -> f64 {
    let (vx1, vy1) = (x1 - x2, y1 - y2);
    let (vx2, vy2) = (x3 - x2, y3 - y2);

    f64::acos(
        (vx1 * vx2 + vy1 * vy2).abs()
            / (f64::sqrt(vx1 * vx1 + vy1 * vy1) * f64::sqrt(vx2 * vx2 + vy2 * vy2)),
    )
}

fn check(r: f64, l1: f64, l2: f64, l3: f64, a1: f64, a2: f64) -> bool {
    let x = r / f64::sin(a1 / 2.0) * f64::cos(a1 / 2.0);
    let y = r / f64::sin(a2 / 2.0) * f64::cos(a2 / 2.0);

    l1 >= 2.0 * r + x + y && l2 >= x && l3 >= y
}

fn main() {
    let a = get!(f64, f64);
    let b = get!(f64, f64);
    let c = get!(f64, f64);

    let mut l = 0.0;
    let mut r = 1000.0;

    for _ in 0..1000 {
        let mid = (l + r) / 2.0;

        if check(
            mid,
            dist(a, b),
            dist(a, c),
            dist(b, c),
            angle(c, a, b),
            angle(a, b, c),
        )
            || check(
                mid,
                dist(a, c),
                dist(b, c),
                dist(a, b),
                angle(a, c, b),
                angle(b, a, c),
            )
            || check(
                mid,
                dist(b, c),
                dist(a, b),
                dist(a, c),
                angle(c, b, a),
                angle(a, c, b),
            ) {
            l = mid;
        } else {
            r = mid;
        }
    }

    println!("{}", (l + r) / 2.0);
}