You are viewing a single comment's thread. Return to all comments →
Scala
object Solution { def main(args: Array[String]) { def len(x: Array[Double], y: Array[Double]): Double = { math.sqrt(math.pow(x(0) - y(0), 2) + math.pow(x(1) - y(1), 2)) } val n = io.StdIn.readLine.toInt val arr = (1 to n).map(_ => io.StdIn.readLine.split(" ").map(_.toDouble)) val p = (0 until n).map(x => len(arr(x), arr((x + 1) % n))).sum println(p) } }
Seems like cookies are disabled on this browser, please enable them to open this website
Compute the Perimeter of a Polygon
You are viewing a single comment's thread. Return to all comments →
Scala