結果
問題 | No.132 点と平面との距離 |
ユーザー |
![]() |
提出日時 | 2016-08-26 15:57:19 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 1,517 bytes |
コンパイル時間 | 163 ms |
コンパイル使用メモリ | 82,428 KB |
実行使用メモリ | 78,228 KB |
最終ジャッジ日時 | 2024-11-08 04:11:09 |
合計ジャッジ時間 | 7,670 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 2 TLE * 1 |
ソースコード
#!/usr/bin/env pypy3import collectionsimport itertoolsimport mathclass 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 productm1 = self.y * other.z - self.z * other.ym2 = self.z * other.x - self.x * other.zm3 = self.x * other.y - self.y * other.xreturn 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): # normreturn 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 - q1v2 = q3 - q2cp = v1 * v2return 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()