結果
問題 | No.132 点と平面との距離 |
ユーザー |
![]() |
提出日時 | 2020-09-13 10:26:05 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 580 ms / 5,000 ms |
コード長 | 1,112 bytes |
コンパイル時間 | 460 ms |
コンパイル使用メモリ | 82,432 KB |
実行使用メモリ | 77,808 KB |
最終ジャッジ日時 | 2024-06-11 18:36:01 |
合計ジャッジ時間 | 2,253 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 3 |
ソースコード
import sysread=sys.stdin.buffer.readreadline=sys.stdin.buffer.readlinereadlines=sys.stdin.buffer.readlinesclass Point:def __init__(self, x, y, z):self.x=xself.y=yself.z=zdef __add__(self, other):return Point(self.x+other.x, self.y+other.y, self.z+other.z)def __sub__(self, other):return Point(self.x-other.x, self.y-other.y, self.z-other.z)def __mul__(self, other):return Point(self.x*other, self.y*other, self.z*other)def dot(self, other):return self.x*other.x+self.y*other.y+self.z*other.zn=int(readline())px, py, pz=map(float, readline().split())p=Point(px, py, pz)xyzs=list(map(float, read().split()))xs=xyzs[::3]ys=xyzs[1::3]zs=xyzs[2::3]qs=[Point(x, y, z) for x, y, z in zip(xs, ys, zs)]import itertools, mathans=0for q1, q2, q3 in itertools.combinations(qs, 3):a, b, c=q1-p, q2-q1, q3-q1ab, ac, bb, bc, cc=a.dot(b), a.dot(c), b.dot(b), b.dot(c), c.dot(c)d=bb*cc-bc*bcs=(-cc*ab+bc*ac)/dt=(bc*ab-bb*ac)/de=a+b*s+c*tans+=math.sqrt(e.dot(e))print('{:.10f}'.format(ans))