結果
| 問題 | No.132 点と平面との距離 | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2017-01-31 14:14:17 | 
| 言語 | D (dmd 2.109.1) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 754 ms / 5,000 ms | 
| コード長 | 1,202 bytes | 
| コンパイル時間 | 2,786 ms | 
| コンパイル使用メモリ | 157,632 KB | 
| 実行使用メモリ | 5,376 KB | 
| 最終ジャッジ日時 | 2024-06-12 06:46:41 | 
| 合計ジャッジ時間 | 4,292 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 3 | 
ソースコード
import std.algorithm, std.conv, std.range, std.stdio, std.string;
import std.math;      // math functions
void main()
{
  auto n = readln.chomp.to!size_t;
  auto pr = readln.split.to!(real[]), p = point(pr[0], pr[1], pr[2]);
  auto qi = n.iota.map!(_ => readln.split.to!(real[])).map!(qr => point(qr[0], qr[1], qr[2])).array;
  auto r = real(0);
  foreach (i; 0..n)
    foreach (j; i+1..n)
      foreach (k; j+1..n)
        r += calc(p, qi[i], qi[j], qi[k]);
  writefln("%.10f", r);
}
auto calc(point p, point q1, point q2, point q3)
{
  auto n = outerProd(q2 - q1, q3 - q1);
  return (n * (p - q1)).abs / n.hypot2.sqrt;
}
struct Point3(T) {
  T x, y, z;
  auto opBinary(string op)(Point3!T rhs) {
    static if (op == "+") return Point3!T(x + rhs.x, y + rhs.y, z + rhs.z);
    else static if (op == "-") return Point3!T(x - rhs.x, y - rhs.y, z - rhs.z);
    else static if (op == "*") return x * rhs.x + y * rhs.y + z * rhs.z;
  }
  T hypot2() { return x ^^ 2 + y ^^ 2 + z ^^ 2; }
}
auto outerProd(T)(Point3!T p1, Point3!T p2)
{
  return Point3!T(p1.y * p2.z - p1.z * p2.y,
                  p1.z * p2.x - p1.x * p2.z,
                  p1.x * p2.y - p1.y * p2.x);
}
alias Point3!real point;
            
            
            
        