結果
問題 | No.132 点と平面との距離 |
ユーザー |
![]() |
提出日時 | 2015-01-20 23:45:48 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 98 ms / 5,000 ms |
コード長 | 1,827 bytes |
コンパイル時間 | 1,381 ms |
コンパイル使用メモリ | 165,088 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-22 23:23:03 |
合計ジャッジ時間 | 1,662 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 3 |
ソースコード
#define _CRT_SECURE_NO_WARNINGS#include <bits/stdc++.h>using namespace std;typedef long long ll;typedef vector<int> vi;typedef vector<vi> vvi;typedef pair<int,int> pii;#define all(c) (c).begin(), (c).end()#define loop(i,a,b) for(ll i=a; i<ll(b); i++)#define rep(i,b) loop(i,0,b)#define pb push_back#define eb emplace_back#define mp make_pair#define mt make_tuple#define lb lower_bound#define ub upper_bound#ifdef DEBUG#define dump(...) (cerr<<#__VA_ARGS__<<" = "<<(DUMP(),__VA_ARGS__).str()<<" ["<<__LINE__<<"]"<<endl)struct DUMP:ostringstream{template<class T>DUMP &operator,(const T&t){if(this->tellp())*this<<", ";*this<<t;return *this;}};#else#define dump(...)#endiftemplate<class T> ostream& operator<<(ostream& os, vector<T> const& v){rep(i,v.size()) os << v[i] << (i+1==v.size()?"":" ");return os;}typedef long double R;typedef tuple<R,R,R> P;#define PCR P const&P cross(PCR a, PCR b){R a1,a2,a3;R b1,b2,b3;tie(a1,a2,a3) = a;tie(b1,b2,b3) = b;return mt(a2*b3-a3*b2, a3*b1-a1*b3, a1*b2-a2*b1);}P operator-(PCR a, PCR b){R a1,a2,a3;R b1,b2,b3;tie(a1,a2,a3) = a;tie(b1,b2,b3) = b;return P(a1-b1, a2-b2, a3-b3);}P p;P ps[400];R dist(int i, int j, int k){R v1,v2,v3;tie(v1,v2,v3) = cross(ps[i]-ps[k],ps[j]-ps[k]);R a1,a2,a3;tie(a1,a2,a3) = ps[k];R d = v1*a1 + v2*a2 + v3*a3;R x,y,z;tie(x,y,z) = p;return abs(v1*x + v2*y + v3*z - d) / sqrt(v1*v1 + v2*v2 + v3*v3);}int main(){int N;while(cin>>N){R x,y,z;cin >> x >> y >> z;p = P(x,y,z);rep(i,N){cin >> x >> y >> z;ps[i] = P(x,y,z);}R ans = 0;rep(i,N)rep(j,i)rep(k,j) ans += dist(i,j,k);printf("%.20lf\n", (double)ans);}}