結果

問題 No.132 点と平面との距離
ユーザー gigurururugigurururu
提出日時 2015-01-21 19:44:34
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 880 bytes
コンパイル時間 1,165 ms
コンパイル使用メモリ 145,524 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-05 02:44:01
合計ジャッジ時間 1,690 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <cassert>

using namespace std;

template <typename T> struct Vector3 {
public:
	T x,y,z;
	Vector3(T x,T y,T z):x(x),y(y),z(z){}
	Vector3(){Vector3(0,0,0);}
	Vector3<T> operator-(const Vector3<T> &o) const { return Vector3<T>(x-o.x,y-o.y,z-o.z); }
	Vector3<T> outer_product(const Vector3<T> &o) const { return Vector3<T>(y*o.z-z*o.y,z*o.x-x*o.z,x*o.y-y*o.x); }
	T inner_product(const Vector3<T> &o) const { return x*o.x+y*o.y+z*o.z; }
	T norm() const { return sqrt(x*x+y*y+z*z); }
};

int main(){
	int n;
	Vector3<double> P,l[300];
	double sum;
	cin>>n;
	cin>>P.x>>P.y>>P.z;
	for(int i=0;i<n;i++){
		cin>>l[i].x>>l[i].y>>l[i].z;
	}
	sum=0;
	for(int i=0;i<n;i++)for(int j=i+1;j<n;j++)for(int k=j+1;k<n;k++){
		Vector3<double> t = (l[j]-l[i]).outer_product(l[k]-l[i]);
		sum += abs(l[i].inner_product(t))/t.norm();
	}
	cout<<sum<<endl;
	return 0;
}
0