結果

問題 No.132 点と平面との距離
ユーザー fumofumofuni
提出日時 2020-12-09 13:03:22
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 298 ms / 5,000 ms
コード長 1,855 bytes
コンパイル時間 2,498 ms
コンパイル使用メモリ 198,256 KB
最終ジャッジ日時 2025-01-16 20:45:04
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 3
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=(n)-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
template<class T> inline bool chmin(T& a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template<class T> inline bool chmax(T& a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
struct P{
double x,y,z;
};
vector<double> pleq(P a,P b,P c){
vector<double> ret(4);
ret[0]=(b.y-a.y)*(c.z-a.z)-(c.y-a.y)*(b.z-a.z);
ret[1]=(b.z-a.z)*(c.x-a.x)-(c.z-a.z)*(b.x-a.x);
ret[2]=(b.x-a.x)*(c.y-a.y)-(c.x-a.x)*(b.y-a.y);
ret[3]=-(ret[0]*a.x+ret[1]*a.y+ret[2]*a.z);
return ret;
}
double dist(vector<double> c,P q){
double ret=abs(c[0]*q.x+c[1]*q.y+c[2]*q.z+c[3]);
ret/=sqrt(c[0]*c[0]+c[1]*c[1]+c[2]*c[2]);
return ret;
}
int main(){
ll n;cin >> n;
P q;cin >> q.x >> q.y >> q.z;
vector<P> p(n);
rep(i,n){
cin >> p[i].x >> p[i].y >> p[i].z;
}
double ret=0;
rep(i,n){
repl(j,i+1,n){
repl(k,j+1,n){
auto x=pleq(p[i],p[j],p[k]);
ret+=dist(x,q);
}
}
}
CST(10);
cout << ret <<endl;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0