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 C# (Mono 4.6.2.0) (judge verdict: Accepted)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
static class Program{
	const int mod=1000000007;
	static void Main(){
		Sc sc=new Sc();
		double[][] p=new double[3][];
		double[][] g=new double[3][];
		double[] l=new double[3];
		for(int i = 0;i<3;i++) {
			p[i]=sc.Da;
			g[i]=new double[]{0,i};
		}
		l[0]=Math.Sqrt((p[0][0]-p[1][0])*(p[0][0]-p[1][0])+(p[0][1]-p[1][1])*(p[0][1]-p[1][1]));
		l[1]=Math.Sqrt((p[1][0]-p[2][0])*(p[1][0]-p[2][0])+(p[1][1]-p[2][1])*(p[1][1]-p[2][1]));
		l[2]=Math.Sqrt((p[2][0]-p[0][0])*(p[2][0]-p[0][0])+(p[2][1]-p[0][1])*(p[2][1]-p[0][1]));
		g[0][0]=Gp4(p[2][0],p[2][1],p[0][0],p[0][1],p[1][0],p[1][1]);
		g[1][0]=Gp4(p[2][0],p[2][1],p[1][0],p[1][1],p[0][0],p[0][1]);
		g[2][0]=180-g[0][0]-g[1][0];
		Array.Sort(g,Ca);
		int k1=(int)g[0][1],k2=(int)g[1][1],l1=0,l2=0,t1=0,t2=0;
		double[] dd0=new double[2];
		if(l[k1]>l[(k1+2)%3]){l1=k1;l2=(k1+2)%3;t1=(k1+2)%3;t2=3-k1-t1;}
		else{l1=(k1+2)%3;l2=k1;t2=(k1+2)%3;t1=3-k1-t2;}
		double d0=p[k1][0]+(p[t1][0]-p[k1][0])*(l[l1]/l[l2]),d1=p[k1][1]+(p[t1][1]-p[k1][1])*(l[l1]/l[l2]);
		dd0=Gp1(p[k1][0],p[k1][1],(p[t2][0]+d0)/2,(p[t2][1]+d1)/2,p[t1][0],p[t1][1],p[t2][0],p[t2][1]);
		
		double[] dd1=new double[2];
		if(l[k2]>l[(k2+2)%3]){l1=k2;l2=(k2+2)%3;t1=(k2+2)%3;t2=3-k2-t1;}
		else{l1=(k2+2)%3;l2=k2;t2=(k2+2)%3;t1=3-k2-t2;}
		d0=p[k2][0]+(p[t1][0]-p[k2][0])*(l[l1]/l[l2]);d1=p[k2][1]+(p[t1][1]-p[k2][1])*(l[l1]/l[l2]);
		dd1=Gp1(p[k2][0],p[k2][1],(p[t2][0]+d0)/2,(p[t2][1]+d1)/2,p[t1][0],p[t1][1],p[t2][0],p[t2][1]);
		double lb0=p[k1][0],lb1=p[k1][1],ub0=dd0[0],ub1=dd0[1],mid0=0,mid1=0;
		double g1=0,g2=0;
		while(Math.Abs(ub0+ub1-lb0-lb1)>1e-10){
			mid0=(ub0+lb0)/2;
			mid1=(ub1+lb1)/2;
			g1=Gp2(p[k1][0],p[k1][1],p[(k1+1)%3][0],p[(k1+1)%3][1],mid0,mid1);
			g2=Gp2(p[k2][0],p[k2][1],dd1[0],dd1[1],mid0,mid1);
			double[] dt=Gp5(p[k2][0],p[k2][1],dd1[0],dd1[1],mid0,mid1);
			double pdt=Math.Sqrt((p[k2][0]-dt[0])*(p[k2][0]-dt[0])+(p[k2][1]-dt[1])*(p[k2][1]-dt[1]));
			double pdt2=pdt-Math.Sqrt(Math.Abs(g1*g1*4-g2*g2));
			if(Gp2(p[k2][0],p[k2][1],p[(k2+1)%3][0],p[(k2+1)%3][1],p[k2][0]+(dt[0]-p[k2][0])*(pdt2/pdt),p[k2][1]+(dt[1]-p[k2][1])*(pdt2/pdt))<g1){ub0=mid0;ub1=mid1;}
			else{lb0=mid0;lb1=mid1;}
		}
		Console.WriteLine(g1);
	}
	static double[] Gp1(double p1x,double p1y,double p2x,double p2y,double p3x,double p3y,double p4x,double p4y){
		double t1=(p4y-p3y)*(p4x-p1x)-(p4x-p3x)*(p4y-p1y);
		double t2=(p2x-p1x)*(p4y-p1y)-(p2y-p1y)*(p4x-p1x);
		double t3=(p2x-p1x)*(p4y-p3y)-(p2y-p1y)*(p4x-p3x);
		double t4=t1/t3,t5=t2/t3;
		return new double[]{p1x+t4*(p2x-p1x),p1y+t4*(p2y-p1y)};
	}
	static double Gp2(double p1x,double p1y,double p2x,double p2y,double p0x,double p0y){
		return Math.Abs((p2y-p1y)*p0x-(p2x-p1x)*p0y+p2x*p1y-p1x*p2y)/Math.Sqrt((p2y-p1y)*(p2y-p1y)+(p2x-p1x)*(p2x-p1x));
	}
	static double Gp4(double ax,double ay,double bx,double by,double cx,double cy){
		double a1=ax-bx,a2=ay-by,c1=cx-bx,c2=cy-by;
		return Math.Acos((a1*c1+a2*c2)/Math.Sqrt((a1*a1+a2*a2)*(c1*c1+c2*c2)))*180/Math.PI;
	}
	static double[] Gp5(double p1x,double p1y,double p2x,double p2y,double p0x,double p0y){
		double rx=p0x,ry=p0y;
		if(p1x==p2x){rx=p1x;}
		else if(p1y==p2y){ry=p1y;}
		else{
			double m1=(p2y-p1y)/(p2x-p1x),b1=p1y-(m1*p1x),m2=-1.0/m1,b2=p0y-(m2*p0x);
			rx=(b2-b1)/(m1-m2);
			ry=(b2*m1-b1*m2)/(m1-m2);
		}
		return new double[]{rx,ry};
	}
	static int Ca(double[] a,double[] b){
		if(a[0]>b[0]){return 1;}
		else if(a[0]<b[0]){return -1;}
		else{return 0;}
	}
}
public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()).Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()).Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
}