結果
問題 | No.132 点と平面との距離 |
ユーザー |
![]() |
提出日時 | 2020-11-21 12:54:46 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 156 ms / 5,000 ms |
コード長 | 1,251 bytes |
コンパイル時間 | 755 ms |
コンパイル使用メモリ | 80,544 KB |
実行使用メモリ | 6,940 KB |
最終ジャッジ日時 | 2024-07-23 15:32:31 |
合計ジャッジ時間 | 1,333 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 3 |
ソースコード
#include <iostream>#include <iomanip>#include <vector>#include <cmath>using namespace std;struct point{double x, y, z;point(){}point(double x, double y, double z): x(x), y(y), z(z){}point operator -(point P){return point(x - P.x, y - P.y, z - P.z);}};double abs(point P){return sqrt(P.x * P.x + P.y * P.y + P.z * P.z);}double dot(point P, point Q){return P.x * Q.x + P.y * Q.y + P.z * Q.z;}point cross(point P, point Q){return point(P.y * Q.z - Q.y * P.z, P.z * Q.x - Q.z * P.x, P.x * Q.y - Q.x * P.y);}double volume(point P, point Q, point R){return abs(dot(cross(P, Q), R));}struct plane{point A, B, C;plane(point A, point B, point C): A(A), B(B), C(C){}};double point_plane_distance(point P, plane T){return abs(volume(P - T.A, T.B - T.A, T.C - T.A)) / abs(cross(T.B - T.A, T.C - T.A));}int main(){cout << fixed << setprecision(15);int N;cin >> N;point P;cin >> P.x >> P.y >> P.z;vector<point> Q(N);for (int i = 0; i < N; i++){cin >> Q[i].x >> Q[i].y >> Q[i].z;}double ans = 0;for (int i = 0; i < N; i++){for (int j = i + 1; j < N; j++){for (int k = j + 1; k < N; k++){ans += point_plane_distance(P, plane(Q[i], Q[j], Q[k]));}}}cout << ans << endl;}