結果
問題 | No.132 点と平面との距離 |
ユーザー | はむ吉🐹 |
提出日時 | 2016-08-26 15:57:19 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 4,911 ms / 5,000 ms |
コード長 | 1,517 bytes |
コンパイル時間 | 195 ms |
コンパイル使用メモリ | 82,456 KB |
実行使用メモリ | 78,624 KB |
最終ジャッジ日時 | 2024-04-25 17:01:25 |
合計ジャッジ時間 | 7,451 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 261 ms
77,088 KB |
testcase_01 | AC | 1,421 ms
77,536 KB |
testcase_02 | AC | 4,911 ms
78,624 KB |
ソースコード
#!/usr/bin/env pypy3 import collections import itertools import math class Vector3(collections.namedtuple("Vector3", "x y z")): __slots__ = () def __add__(self, other): return Vector3(*(s + o for s, o in zip(self, other))) def __sub__(self, other): return Vector3(*(s - o for s, o in zip(self, other))) def __mul__(self, other): # cross product m1 = self.y * other.z - self.z * other.y m2 = self.z * other.x - self.x * other.z m3 = self.x * other.y - self.y * other.x return Vector3(m1, m2, m3) def __neg__(self): return Vector3(-self.x, -self.y, -self.z) def __pos__(self): return Vector3(+self.x, +self.y, +self.z) def __abs__(self): # norm return math.sqrt(sum(s * s for s in self)) def dotproduct(self, other): return sum(s * o for s, o in zip(self, other)) def angle(self, other): return math.acos(self.dotproduct(other) / abs(self) / abs(other)) def scale(self, k): return Vector3(k * self.x, k * self.y, k * self.z) def dist(q1, q2, q3): v1 = q2 - q1 v2 = q3 - q2 cp = v1 * v2 return abs(q1.dotproduct(cp)) / abs(cp) def solve(p, qs): return sum(dist(*q123) for q123 in itertools.combinations(qs, 3)) def main(): n = int(input()) p = Vector3(*map(float, input().split())) qs = [Vector3(*map(float, input().split())) - p for _ in range(n)] print("{:.12f}".format(solve(p, qs))) if __name__ == '__main__': main()