SPOJ 2716. Maximal Quadrilateral Area (QUADAREA) with F#

Problem Definition

Details about this problem is available here.  Required Background Topic:  Cyclic quadrilateral.


Given that the length of the sides are {a,b,c,d}, the Maximal Quadrilateral Area is given by the following equation:

where semiperimeter s can be defined as follows.

let getMaxQuadrilateralArea (a,b,c,d) =
let s = 0.50 *(a+b+c+d)
let solveSpoj2716() =
let parseLine() =
let l = System.Console.ReadLine().Split()
let rec runTests currentTest maxAvailableTests =
if currentTest < maxAvailableTests then
|> getMaxQuadrilateralArea
|> printfn "%f"
runTests (currentTest+1) maxAvailableTests
match System.Console.ReadLine() |> System.Int32.TryParse with
| (true, i) when i > 0 -> runTests 0 i
| _ -> ()
view raw QUADAREA.fs hosted with ❤ by GitHub

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: