No.132 Distance Between a Point and a Plane
タグ : / 解いたユーザー数 115
作問者 :
LayCurse
Problem Statement
You are given a point \(P\) in \(3\)-dimensional space and \(N\) points \(Q_1,Q_2,\ldots,Q_N\).
Let \({\rm dist}(i,j,k)\) denote the distance between point $P$ and the plane passing through points $Q_i,Q_j,Q_k$.
Write a program that computes the sum of the distances between point $P$ and the planes passing through $Q_i,Q_j,Q_k$.
In other words, write a program that computes the value of \(\displaystyle \sum_{1 \leq i < j < k \leq N} {\rm dist}(i,j,k)\).
The distance between a point $x$ and a plane $y$ is the distance between point $x$ and the foot of the perpendicular dropped from point $x$ to plane $y$.
Input
\(N\) \(P_x\ P_y\ P_z\) \(X_1\ Y_1\ Z_1\) \(X_2\ Y_2\ Z_2\) \(\vdots\) \(X_N\ Y_N\ Z_N\)
\(N \in \{100,200,300\}\)
\(-1000 \leq P_x, P_y, P_z \leq 1000\): the coordinates of point $P$
\(-1000 \leq X_k, Y_k, Z_k \leq 1000\): the coordinates of point $Q_k$
Each coordinate is given with exactly \(6\) digits after the decimal point.
Each coordinate is generated randomly, and you may assume that no \(3\) points are collinear and no \(4\) points are coplanar.
Note: The samples may not satisfy the constraints, but the judge data do satisfy them.
The judge data consist of \(3\) test cases in total, with \(N\) values of \(100,200,300\) respectively.
Output
Output the answer.
Your answer is considered correct if its absolute error or relative error is at most \(10^{-9}\).
Print a newline at the end.
Sample
Sample 1
Input
3 0 0 4 1 2 0 3 7 0 9 1 0
Output
4
The plane containing $Q_1,Q_2,Q_3$ is the $xy$ plane, and the distance between point $(0,0,4)$ and the $xy$ plane is $4$.
Sample 2
Input
10 -901.024872 472.789306 269.177382 239.060492 -23.854948 622.357515 -514.916227 738.906828 51.113001 682.200955 558.639699 -442.006273 -984.691228 416.424662 558.734465 -236.365727 714.654054 -545.868635 461.190971 -796.064539 -525.621408 20.844384 370.876071 775.750981 203.292480 -121.700220 -508.251995 -792.927906 448.669892 976.681305 -85.515212 941.493450 -517.440208
Output
47386.06556925852
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。