結果
| 問題 | No.132 点と平面との距離 |
| コンテスト | |
| ユーザー |
tottoripaper
|
| 提出日時 | 2019-03-09 16:20:53 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 38 ms / 5,000 ms |
| コード長 | 1,634 bytes |
| 記録 | |
| コンパイル時間 | 1,479 ms |
| コンパイル使用メモリ | 168,852 KB |
| 実行使用メモリ | 6,940 KB |
| 最終ジャッジ日時 | 2024-06-23 15:13:19 |
| 合計ジャッジ時間 | 1,980 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 3 |
ソースコード
#include <bits/stdc++.h>
#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))
using ll = std::int64_t;
struct Point{
double x, y, z;
Point() = default;
Point(double x, double y, double z) : x(x), y(y), z(z) {}
double abs(){
return std::sqrt(x * x + y * y + z * z);
}
Point& operator+=(Point &rhs){
x += rhs.x; y += rhs.y; z += rhs.z;
return *this;
}
friend Point operator+(Point lhs, Point &rhs){return lhs += rhs;}
Point& operator-=(Point &rhs){
x -= rhs.x; y -= rhs.y; z -= rhs.z;
return *this;
}
friend Point operator-(Point lhs, Point &rhs){return lhs -= rhs;}
friend std::istream& operator>>(std::istream &is, Point &p){return is >> p.x >> p.y >> p.z;}
};
Point cross(Point p, Point q){
return {p.y * q.z - p.z * q.y, -(p.x * q.z - p.z * q.x), p.x * q.y - p.y * q.x};
}
double dot(Point p, Point q){
return p.x * q.x + p.y * q.y + p.z * q.z;
}
int N;
Point p, qs[300];
int main(){
std::cin.tie(nullptr);
std::ios::sync_with_stdio(false);
std::cin >> N;
std::cin >> p;
for(int i=0;i<N;++i){
std::cin >> qs[i];
}
double sum = 0;
for(int i=0;i<N;++i){
for(int j=i+1;j<N;++j){
for(int k=j+1;k<N;++k){
Point n = cross(qs[j] - qs[i], qs[k] - qs[i]);
double d = dot(qs[i], n);
double dist = std::abs(dot(p, n) - d) / n.abs();
sum += dist;
}
}
}
printf("%.10f\n", sum);
}
tottoripaper