結果

問題 No.132 点と平面との距離
ユーザー gigurururugigurururu
提出日時 2015-01-21 00:44:55
言語 Ruby
(3.3.0)
結果
TLE  
実行時間 -
コード長 544 bytes
コンパイル時間 447 ms
コンパイル使用メモリ 11,476 KB
実行使用メモリ 32,192 KB
最終ジャッジ日時 2023-09-05 02:41:10
合計ジャッジ時間 10,075 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,331 ms
32,192 KB
testcase_01 TLE -
testcase_02 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

require 'matrix'
class Vector
  def outer_product(o)
    raise 'outer_product is size3 only(size#{self.size})' unless size == 3
    Vector[
      self[1]*o[2]-self[2]*o[1],
      self[2]*o[0]-self[0]*o[2],
      self[0]*o[1]-self[1]*o[0],
    ]
  end
end

def g;gets.split.map(&:to_f)end
def cross(a,b)
[a[1]*b[2]-a[2]-b[1],a[2]*b[0]-a[0]*b[2],a[0]*b[1]-a[1]*b[0]]
end
n=gets.to_i
p=Vector[*g]
q=(1..n).map{Vector[*g]}
sum=0
q.combination(3){|a,b,c|
  t=(b-a).outer_product(c-a)
  sum+=(p.inner_product(t)-a.inner_product(t)).abs/t.norm
}
p sum
0