結果

問題 No.132 点と平面との距離
ユーザー kotatsugamekotatsugame
提出日時 2020-03-04 10:30:12
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 47 ms / 5,000 ms
コード長 627 bytes
コンパイル時間 576 ms
コンパイル使用メモリ 75,768 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-22 01:00:26
合計ジャッジ時間 1,069 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,376 KB
testcase_01 AC 17 ms
5,376 KB
testcase_02 AC 47 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:18:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   18 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;
struct Point{double x,y,z;}P,Q[300];
void in(Point&p){cin>>p.x>>p.y>>p.z;}
int N;
double dist(Point A,Point B,Point C)
{
	B.x-=A.x;B.y-=A.y;B.z-=A.z;
	C.x-=A.x;C.y-=A.y;C.z-=A.z;
	double a=B.y*C.z-B.z*C.y;
	double b=B.z*C.x-B.x*C.z;
	double c=B.x*C.y-B.y*C.x;
	double d=-a*A.x-b*A.y-c*A.z;
	return abs(a*P.x+b*P.y+c*P.z+d)/sqrt(a*a+b*b+c*c);
}
main()
{
	cin>>N;
	in(P);
	for(int i=0;i<N;i++)in(Q[i]);
	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++)ans+=dist(Q[i],Q[j],Q[k]);
	cout<<fixed<<setprecision(16)<<ans<<endl;
}
0