結果

問題 No.132 点と平面との距離
ユーザー gigurururugigurururu
提出日時 2015-01-22 17:39:42
言語 Scala(Beta)
(3.4.0)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 898 bytes
コンパイル時間 7,380 ms
コンパイル使用メモリ 250,540 KB
最終ジャッジ日時 2024-04-27 02:06:12
合計ジャッジ時間 7,780 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
-- [E100] Syntax Error: Main.scala:19:46 ---------------------------------------
19 |    scala.math.abs(a(0).inner_product(t)) / t.norm
   |                                            ^^^^^^
   |            method norm in class Vector3 must be called with () argument
   |
   | longer explanation available when compiling with `-explain`
1 error found

ソースコード

diff #

import scala.io.StdIn

class Vector3(_x: Double, _y: Double, _z: Double) {
  val (x, y, z) = (_x, _y, _z)
  def this() = this(0, 0, 0)
  def this(a: Array[Double]) = this(a(0), a(1), a(2))
  def -(o: Vector3): Vector3 = new Vector3(x - o.x, y - o.y, z - o.z)
  def cross_product(o: Vector3): Vector3 = new Vector3(y * o.z - z * o.y, z * o.x - x * o.z, x * o.y - y * o.x)
  def inner_product(o: Vector3): Double = x * o.x + y * o.y + z * o.z
  def norm(): Double = scala.math.sqrt(x * x + y * y + z * z)
}

object Main extends App {
  val n: Int = StdIn.readInt()
  val p: Vector3 = new Vector3(StdIn.readLine().split(" ").map(_.toDouble))
  val l = (1 to n).map(_ => new Vector3(StdIn.readLine().split(" ").map(_.toDouble)) - p)
  val ans = l.combinations(3).map { a =>
    val t = (a(1) - a(0)).cross_product(a(2) - a(0))
    scala.math.abs(a(0).inner_product(t)) / t.norm
  }.sum
  println(ans)
}
0