結果

問題 No.132 点と平面との距離
ユーザー ytftytft
提出日時 2021-03-14 19:14:42
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 70 ms / 5,000 ms
コード長 1,163 bytes
コンパイル時間 1,694 ms
コンパイル使用メモリ 168,744 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-24 01:53:40
合計ジャッジ時間 2,204 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main(){
    int N;
    cin>>N;
    vector<double> P(3);
    for(int i=0;i<3;i++){
        cin>>P[i];
    }
    vector<vector<double>> Q(N,vector<double>(3));
    for(int i=0;i<N;i++){
        for(int j=0;j<3;j++){
            cin>>Q[i][j];
            Q[i][j]-=P[j];
        }
    }
    vector<double> a(3),b(3),law(3);
    double length;
    double product;
    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++){
                for(int l=0;l<3;l++){
                    a[l]=Q[i][l]-Q[k][l];
                    b[l]=Q[j][l]-Q[k][l];
                } 
                length=0;
                for(int l=0;l<3;l++){
                    law[l]=a[(l+1)%3]*b[(l+2)%3]-a[(l+2)%3]*b[(l+1)%3];
                    length+=law[l]*law[l];
                }
                length=sqrt(length);
                product=0;
                for(int l=0;l<3;l++){
                    product+=law[l]*Q[k][l];
                }
                ans+=abs(product/length);
            }
        }
    }
    cout << std::fixed << std::setprecision(15) << ans << endl;
}
0