Skip to content

Instantly share code, notes, and snippets.

@adilakhter

adilakhter/QUADAREA.fs

Last active Dec 10, 2015
Embed
What would you like to do?
F# | SPOJ 2716. Maximal Quadrilateral Area
let getMaxQuadrilateralArea (a,b,c,d) =
let s = 0.50 *(a+b+c+d)
System.Math.Sqrt((s-a)*(s-b)*(s-c)*(s-d))
let solveSpoj2716() =
let parseLine() =
let l = System.Console.ReadLine().Split()
(l.[0]|>float,l.[1]|>float,l.[2]|>float,l.[3]|>float)
let rec runTests currentTest maxAvailableTests =
if currentTest < maxAvailableTests then
parseLine()
|> getMaxQuadrilateralArea
|> printfn "%f"
runTests (currentTest+1) maxAvailableTests
in
match System.Console.ReadLine() |> System.Int32.TryParse with
| (true, i) when i > 0 -> runTests 0 i
| _ -> ()
solveSpoj2716()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.