結果

問題 No.132 点と平面との距離
ユーザー te-shte-sh
提出日時 2016-09-06 16:45:55
言語 D
(dmd 2.106.1)
結果
TLE  
実行時間 -
コード長 1,066 bytes
コンパイル時間 2,388 ms
コンパイル使用メモリ 180,908 KB
実行使用メモリ 8,444 KB
最終ジャッジ日時 2023-09-02 21:57:29
合計ジャッジ時間 10,761 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 994 ms
4,368 KB
testcase_01 TLE -
testcase_02 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.algorithm, std.array, std.container, std.range, std.bitmanip;
import std.numeric, std.math, std.bigint, std.random, core.bitop;
import std.string, std.regex, std.conv, std.stdio, std.typecons;

struct point {
  real x, y, z;
}

void main()
{
  auto n = readln.chomp.to!size_t;
  auto ai = iota(n + 1)
    .map!(_ => readln.split.map!(to!real))
    .map!(rd => point(rd[0], rd[1], rd[2])).array;
  auto p = ai.front;
  auto qi = ai[1..$];

  auto bi = new bool[](n);
  bi[3..$] = true;

  real s = 0;
  do {
    auto r = qi.zip(bi).filter!("!a[1]").map!("a[0]").array;

    auto a = (r[1].y - r[0].y) * (r[2].z - r[0].z) - (r[2].y - r[0].y) * (r[1].z - r[0].z);
    auto b = (r[1].z - r[0].z) * (r[2].x - r[0].x) - (r[2].z - r[0].z) * (r[1].x - r[0].x);
    auto c = (r[1].x - r[0].x) * (r[2].y - r[0].y) - (r[2].x - r[0].x) * (r[1].y - r[0].y);
    auto d = -(a * r[0].x + b * r[0].y + c * r[0].z);

    auto t = (a * p.x + b * p.y + c * p.z + d).abs / (a ^^ 2 + b ^^ 2 + c ^^ 2).sqrt;
    s += t;
  } while(bi.nextPermutation);

  writefln("%.9f", s);
}
0