結果
| 問題 | No.132 点と平面との距離 | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2018-10-16 00:03:44 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 35 ms / 5,000 ms | 
| コード長 | 1,259 bytes | 
| コンパイル時間 | 1,327 ms | 
| コンパイル使用メモリ | 161,780 KB | 
| 実行使用メモリ | 5,248 KB | 
| 最終ジャッジ日時 | 2024-10-12 18:38:03 | 
| 合計ジャッジ時間 | 1,808 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 3 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
template<typename T>
struct Vector3 {
	T x,y,z;
	Vector3 operator+(const Vector3 &v) {
		return { x + v.x, y + v.y, z + v.z };
	}
	Vector3 operator-(const Vector3 &v) {
		return { x - v.x, y - v.y, z - v.z };
	}
	T dot(const Vector3 &v) {
		return  x * v.x + y * v.y + z * v.z;
	}
	Vector3 cross(Vector3 v) {
		return {
			y * v.z - z * v.y,
			z * v.x - x * v.z,
			x * v.y - y * v.x
		};
	}
	T abs() {
        return sqrt(x * x + y * y + z * z);
    }
};
int main() {
    #ifdef DEBUG
    std::ifstream in("/home/share/inputf.in");
    std::cin.rdbuf(in.rdbuf());
    #endif
    int N;
    cin >> N;
    Vector3<double> P;
    vector<Vector3<double>> V(N);
    cin >> P.x >> P.y >> P.z;
    for(int i = 0; i < N; i++) {
        cin >> V[i].x >> V[i].y >> V[i].z;
    }
    double ans = 0;
    // O(N^3)
    for(int i = 0; i < N; i++) {
        for(int j = i + 1; j < N; j++) {
            Vector3<double> v1 = V[j] - V[i];
            for(int k = j + 1; k < N; k++) {
                Vector3<double> norm = v1.cross(V[k] - V[i]);
                ans += abs(norm.dot(P) - norm.dot(V[i])) / norm.abs();
            }
        }
    }
    cout << std::fixed << std::setprecision(15) << ans << endl;
    return 0;
}
            
            
            
        