#include #include #include #include #include #include #include #include #include #include #include #include #include #define repd(i,a,b) for (int i=(a);i<(b);i++) #define rep(i,n) repd(i,0,n) #define var auto #define mod 1000000007 #define inf 2147483647 #define nil -1 typedef long long ll; using namespace std; int inputValue(){ int a; cin >> a; return a; } template void output(T a, int precision) { if(precision > 0){ cout << fixed << setprecision(precision) << a << "\n"; } else{ cout << a << "\n"; } } class vec3 { public: double x; double y; double z; vec3(){ } vec3(double x, double y, double z){ this -> x = x; this -> y = y; this -> z = z; } vec3 & operator += (const vec3 &a) { this -> x += a.x; this -> y += a.y; this -> z += a.z; return *this; } vec3 & operator -= (const vec3 &a) { this -> x -= a.x; this -> y -= a.y; this -> z -= a.z; return *this; } vec3 operator + (const vec3 &a) const { vec3 ret = *this; ret += a; return ret; } vec3 operator - (const vec3 &a) const { vec3 ret = *this; ret -= a; return ret; } }; double length(vec3 a, vec3 b){ double ret = (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y) + (a.z - b.z) * (a.z - b.z); return sqrt(ret); } double det(vec3 a, vec3 b, vec3 c){ return abs(a.x * b.y * c.z + a.y * b.z * c.x + a.z * b.x * c.y - a.x * b.z * c.y - a.y * b.x * c.z - a.z * b.y * c.x); } // end of template double dist(vec3 x0, vec3 x1, vec3 x2, vec3 x3){ double a = length(x0, x1); double b = length(x1, x2); double c = length(x2, x0); x1 -= x0; x2 -= x0; x3 -= x0; // volume of tetrahedral * 6 = det(x1, x2, x3) double d = det(x1, x2, x3); // output(d, 10); // area of bottom triangle double s = (a + b + c) / 2; double area = sqrt(s * (s - a) * (s - b) * (s - c)); // output(area, 10); return d / (2 * area); } int main() { cin.tie(0); // source code int N = inputValue(); vec3 p; cin >> p.x >> p.y >> p.z; vector q(N); rep(i, N){ cin >> q[i].x >> q[i].y >> q[i].z; } double ret = 0; rep(i, N) repd(j, i + 1, N) repd(k, j + 1, N){ ret += dist(q[i], q[j], q[k], p); } output(ret, 10); return 0; }