結果
問題 | No.132 点と平面との距離 |
ユーザー |
![]() |
提出日時 | 2022-12-24 04:23:36 |
言語 | C++17(clang) (17.0.6 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 61 ms / 5,000 ms |
コード長 | 1,114 bytes |
コンパイル時間 | 3,605 ms |
コンパイル使用メモリ | 143,072 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-18 05:07:32 |
合計ジャッジ時間 | 1,759 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 3 |
ソースコード
#include <iostream>#include <vector>#include <cmath>#include <map>#include <set>#include <iomanip>#include <queue>#include <algorithm>#include <numeric>#include <deque>#include <complex>using namespace std;using ld = long double;vector<ld> x, y, z;ld dist(int i, int j, int k){ld dx1, dx2, dy1, dy2, dz1, dz2, a, b, c, d;dx1 = x[j]-x[i];dy1 = y[j]-y[i];dz1 = z[j]-z[i];dx2 = x[k]-x[i];dy2 = y[k]-y[i];dz2 = z[k]-z[i];a = dy1*dz2 - dz1*dy2;b = dz1*dx2 - dx1*dz2;c = dx1*dy2 - dy1*dx2;d = a * x[i] + b * y[i] + c * z[i];return abs(d)/sqrt(a*a+b*b+c*c);}int main(){int N;cin >> N;x.resize(N); y.resize(N), z.resize(N);ld px, py, pz, xx, yy, zz, ans=0;cin >> px >> py >> pz;for (int i=0; i<N; i++){cin >> xx >> yy >> zz;x[i] = xx-px;y[i] = yy-py;z[i] = zz-pz;}for (int i=0; i<N; i++){for (int j=i+1; j<N; j++){for (int k=j+1; k<N; k++) ans += dist(i, j, k);}}cout << setprecision(18) << ans << endl;return 0;}