Practice on Toph

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

Robin Sparkles

Limits: 1s, 1.0 GB

Robin Sparkle went to the mall one day. While shopping, she remembered that she has a homework due the next day. She recalled that she has to solve a problem regarding a quadrilateral inscribed in a circle.

Robin gives you the following information about the quadrilateral:

$a,b,c$: Lengths of three arbitrarily chosen sides of the quadrilateral.
$r$: Radius of the circle it is inscribed in.

Help her calculate the area of the quadrilateral. Robin’s robot has broken down trying to solve this problem. You are her only hope.


The first line of the input will contain an integer $T$ denoting the number of test cases. $T$ lines follow. Each of these lines contain four positive real numbers $a, b, c$ and $r$. These numbers may contain up to 7 digits after the decimal point.


$1\leq T\leq 10^5$
$0<a,b,c \leq 2r$
The sum of lengths of the arcs cut by any two of the given sides is greater than or equal to the length of the arc cut by the other side. You can safely assume that the sides form a simple convex polygon and the fourth side has a positive length.


For each case, you have to print the area of the inscribed quadrilateral on a separate line. Absolute error less than $10^{-6}$ will be ignored.


14.1421356 14.1421356 14.1421356 10
7 7 7 5

This image represents the first case given in the sample. The radius is of length $10$ and the lengths sides of the quadrilateral are same, $10\sqrt 2$. Hence, the area of the quadrilateral is $(10\sqrt 2)^2 = 200$.

  • Labib666's Avatar


    Labib loves to solve problems unless confronted with real life ones which he procrastinates upon with food and sitcoms.

Login to submit