Given triangle vertex coordinates and a measured incircle radius, compute the radius from the formula and print the percentage difference.
Easy2GeometryMathImplementationNo attempts yetTime limit2sMemory limit512 MBTim is quite a bookworm. Every Saturday he goes to the local library and spends the whole day reading old books. He is mostly interested in ancient history, but from time to time he also reads scientific books. Last weekend he found a series of twelve books called "The Elements", written by some old Greek called Euclid. Tim had never heard of him. All twelve books were filled with definitions, propositions and proofs about elementary geometry.
Tim read every book very carefully, but one handwritten note stuck in his mind. Someone had written this just after Book 4, Proposition 4.
Using Heron's formula, one can easily derive that the following identity holds for a triangle with incircle radius r, area A, and side lengths a, b, c.
A=r⋅2a+b+c
Tim is not a very trusting person, so he does not believe that this formula is correct. He does remember from school that Heron's formula states a relationship between the area of a triangle and the lengths of its three sides, and that formula he trusts.
A=414a2b2−(a2+b2−c2)2
To check the formula he found in the book, Tim constructed a lot of triangles on paper, inscribed their incircles and measured the radius. Now he wants to compare his measurements against the formula, but he is already tired from drawing all those triangles. Write a program that reads the coordinates of a triangle's vertices, computes the incircle radius from the formula in the book, and prints the difference to the measured value as a percentage.
Each of the first three lines contains two integers xi and yi (−103≤xi,yi≤103, 1≤i≤3), the coordinates of one vertex of the triangle.
The fourth line contains one real number r (0.1≤r≤106), the incircle radius Tim measured on the triangle he drew on paper.
The three coordinates are never collinear. The area of the triangle is always at least 0.1.
Print, on one line, the difference between the radius computed from the formula and the measured radius as a percentage, where the measured radius is 100 percent. If r′ is the computed radius, print
rr′−r×100
rounded to three digits after the decimal point, with exactly three digits after the decimal point. The value is positive when the computed radius is larger than the measured one, 0 when they are equal, and negative otherwise. When the rounded result is zero, print 0.000 and not -0.000.