TETRA - Sphere in a tetrahedron

no tags 

Of course a Sphere Online Judge System is bound to have some tasks about spheres. So here is one. Given the lengths of the edges of a tetrahedron calculate the radius of a sphere inscribed in that tetrahedron (i.e. a sphere tangent to all the faces).


Number N of test cases in a single line. ( N <= 30 ) Each of the next N lines consists of 6 integer numbers -- the lengths of the edges of a tetrahedron separated by single spaces. The edges are not longer than 1000 and for the tetrahedron WXYZ, the order of the edges is: WX, WY, WZ, XY, XZ, YZ.


N lines, each consisting of a real number given with four digits decimal precision equal to the radius of a sphere inscribed in the given tetrahedron.


1 1 1 1 1 1
1000 999 998 5 5 6


hide comments
mohanish2504: 2019-04-14 12:55:31

Do the following:
1.Take six edges a,b,c,d,e,f
2.CALCULATE volume by link given below
3.Calculate 4 surfaces and add them as SurfaceArea
4.Formula for radius of sphere = (3*vol)/SurfaceArea
5.set precision for 4 units and u are done with AC

Link for volume:

nguyenthihang: 2018-06-09 12:34:33

1 1 1 1 1 1
1000 999 998 5 5 6

mayankdhyani: 2018-04-07 21:28:54

If sides are equal then apply the formula r(radii of sphere) = [ side*sqrt(6) ] / 12. i got my code wrong but my answer of first condition (1 1 1 1 1 1) was correct. please someone upload full program of this question. I dont understand if sides are different of tetrahedron then how sphere will get into it with same radii ?

Last edit: 2018-04-07 21:31:48
nik12321: 2017-04-13 11:17:10

Why can't we use the formula for volume of a tetrahedron as
We can take any face as base and the length of opposite side as height.
Tried and gave the wrong answer

scorpion_ajay: 2017-01-13 19:30:35


vinit_coder: 2016-08-13 19:21:17

go to http://rigmer.com and search this problem.

pranjalikumar9: 2016-05-20 21:07:29

Calculate area of faces using herons formula and then radius of insphere is a simple formula r=3*v/(a1+a2+a3+a4)
where v is volume of tetrahedron.. Solve pyramids before this question

tomasznowak: 2015-12-11 13:58:14

If you have good answers for the example and SPOJ gives "Wrong Answer", then you probably don't include the situation, where one (or more) of the edges is 0. If one is zero, therefore the radius is 0. Your program should also write 0 not as "0", but as "0.0000".

shubhamg gupta: 2015-12-06 20:49:24

Last edit: 2015-12-13 20:04:50
Kaushik Nath: 2015-01-18 07:38:31

Remember to take care of the decimal places
It should be only 4

Added by:Adam Dzedzej
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: NODEJS PERL6 VB.NET