Tuesday, August 19, 2014

Triangle From Centroid


Problem Link : http://www.spoj.com/problems/TRICENTR/

Idea: If distances from centroid to side a,b and c are ga,gb and gc respectively.
The height of the triangle is 3*ga , 3*gb and 3*gc. So we can calculate the area of the triangle easily by this formula-
           Area=a*ga*3/2                where,base is a and height is ga*3   
Now we have to calculate side b and c.
Look,we know the area of the triangle,the height of the triangle.It is quite simple to calculate side b and c.
            Area=b*gb*3/2.               where,base is b and height is gb*3
         So, b=(2*Area)/(3*gb)
 Similarly,  c=(2*Area)/(3*gc)
Now the radius of circumcircle is
R= (a*b*c)/(4*Area)
Distance from Orthocenter of the triangle to the center of the circumcircle of the triangle HO is-
HO=sqrt(9*R*R-a*a-b*b-c*c)
We know that,the distance from Orthocenter of the triangle to the centroid of the triangle HG is-
HG=2*HO/3

Our answer is Area and HG :)

My Solution : http://pastebin.com/mUyePC2u


1 comment: