結果
問題 | No.132 点と平面との距離 |
ユーザー |
![]() |
提出日時 | 2015-01-22 23:48:25 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 40 ms / 5,000 ms |
コード長 | 1,775 bytes |
コンパイル時間 | 914 ms |
コンパイル使用メモリ | 72,160 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-23 00:35:13 |
合計ジャッジ時間 | 1,445 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 3 |
ソースコード
#include <iostream>#include <iomanip>#include <cmath>#include <vector>#define FORR(i,b,e) for(int i=(b);i<(int)(e);++i)#define FOR(i,e) FORR(i,0,e)#define dump(var) cerr << #var ": " << var << "\n"#define dumpc(con) for(auto& e: con) cerr << e << " "; cerr<<"\n"typedef long long ll;typedef unsigned long long ull;using namespace std;struct Vector3D {double x, y, z;Vector3D(){}Vector3D(double x, double y, double z): x(x), y(y), z(z) {}Vector3D(const Vector3D &v) {x = v.x; y = v.y; z = v.z;}Vector3D operator+(const Vector3D &v) const {return Vector3D(x+v.x, y+v.y, z+v.z);}Vector3D operator-(const Vector3D &v) const {return Vector3D(x-v.x, y-v.y, z-v.z);}double length() { return sqrt(x*x+y*y+z*z); }void normalize() {double l = length();x/=l; y/=l; z/=l;}double dot(const Vector3D &v) {return x*v.x + y*v.y + z*v.z;}Vector3D cross(const Vector3D &v) {return Vector3D(y * v.z - z * v.y,z * v.x - x * v.z,x * v.y - y * v.x);}};int main() {cin.tie(0);ios::sync_with_stdio(false);int N;cin >> N;Vector3D p;vector<Vector3D> v(N);cin >> p.x >> p.y >> p.z;FOR(i, N) cin >> v[i].x >> v[i].y >> v[i].z;Vector3D vp, v1, v2, normal;double length = 0;v1 = v[1] - v[0];FOR(i, N) FOR(j, i) {vp = v[i] - p;v1 = v[j] - v[i];FOR(k, j) {v2 = v[k] - v[j];normal = v1.cross(v2);normal.normalize();length += abs(vp.dot(normal));}}cout << fixed << setprecision(10);cout << length << endl;return 0;}