結果

問題 No.132 点と平面との距離
ユーザー koyumeishikoyumeishi
提出日時 2015-01-21 00:26:36
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 44 ms / 5,000 ms
コード長 1,361 bytes
コンパイル時間 598 ms
コンパイル使用メモリ 75,852 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-05 02:40:27
合計ジャッジ時間 1,289 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
4,356 KB
testcase_01 AC 15 ms
4,380 KB
testcase_02 AC 44 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <cstdio>
#include <sstream>
#include <map>
#include <string>
#include <algorithm>
#include <queue>
#include <cmath>
#include <set>
using namespace std;


class xyz{
public:
	double x;
	double y;
	double z;

	xyz(){
		
	}
	
	xyz(double xx, double yy, double zz){
		x = xx;
		y = yy;
		z = zz;
	}

	xyz(const xyz &v){
		x = v.x;
		y = v.y;
		y = v.z;
	}

	xyz& operator=(const xyz &v){
		x = v.x;
		y = v.y;
		z = v.z;
		return *this;
	}
	
	xyz operator+(const xyz &v) const{
		return xyz(this->x+v.x, this->y+v.y, this->z+v.z);
	}
	
	xyz operator-(const xyz &v) const{
		return xyz(this->x-v.x, this->y-v.y, this->z-v.z);
	}
};

xyz cross(const xyz &u, const xyz &v){
	return xyz( u.y*v.z-u.z*v.y, u.z*v.x-u.x*v.z, u.x*v.y-u.y*v.x);
}

double dot(const xyz &u, const xyz &v){
	return u.x*v.x + u.y*v.y + u.z*v.z;
}



int main(){
	int n;
	cin >> n;
	double px,py,pz;
	cin >> px >> py >> pz;
	xyz p(px,py,pz);

	vector<xyz> q(n);
	for(int i=0; i<n; i++){
		double x,y,z;
		cin >> x >> y >> z;
		q[i] = xyz(x,y,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++){

				xyz w = cross(q[j]-q[i], q[k]-q[i]);
				double wd = -w.x*q[i].x -w.y*q[i].y -w.z*q[i].z;

				ans += abs( dot(p,w) + wd )/sqrt(dot(w,w));
				
			}
		}
	}
	printf("%.11f\n", ans);
	
	return 0;
}
0