結果
問題 |
No.132 点と平面との距離
|
ユーザー |
|
提出日時 | 2020-06-08 00:55:08 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 40 ms / 5,000 ms |
コード長 | 644 bytes |
コンパイル時間 | 2,497 ms |
コンパイル使用メモリ | 193,896 KB |
最終ジャッジ日時 | 2025-01-11 00:01:34 |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 3 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:9:31: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 9 | double x0,y0,z0; scanf("%d%lf%lf%lf",&n,&x0,&y0,&z0); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ main.cpp:11:23: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 11 | rep(i,n) scanf("%lf%lf%lf",&x[i],&y[i],&z[i]); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for(int i=0;i<(n);i++) using namespace std; int main(){ int n; double x0,y0,z0; scanf("%d%lf%lf%lf",&n,&x0,&y0,&z0); vector<double> x(n),y(n),z(n); rep(i,n) scanf("%lf%lf%lf",&x[i],&y[i],&z[i]); double ans=0; rep(i,n) rep(j,i) rep(k,j) { double vx=x[j]-x[i]; double vy=y[j]-y[i]; double vz=z[j]-z[i]; double wx=x[k]-x[i]; double wy=y[k]-y[i]; double wz=z[k]-z[i]; double nx=vy*wz-vz*wy; double ny=vz*wx-vx*wz; double nz=vx*wy-vy*wx; double a=nx,b=ny,c=nz,d=-nx*x[i]-ny*y[i]-nz*z[i]; ans+=abs(a*x0+b*y0+c*z0+d)/sqrt(a*a+b*b+c*c); } printf("%.15f\n",ans); return 0; }