// yukicoder: No.132 点と平面との距離 // 2019.8.2 bal4u #include #include #if 1 #define gc() getchar_unlocked() #define pc(c) putchar_unlocked(c) #else #define gc() getchar() #define pc(c) putchar(c) #endif int in() { // 非負整数の入力 int n = 0, c = gc(); do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0'); return n; } double getdbl() { // 実数の入力 int minus = 0; double x, y; int n = 0, c = gc(); if (c == '-') minus = 1, c = gc(); do n = 10*n + (c & 0xf), c = gc(); while (c >= '0'); if (c == '.') { x = 0; y = 1, c = gc(); do y *= 0.1, x += y * (c & 0xf), c = gc(); while (c >= '0'); x += n; } else x = n; if (minus) x = -x; return x; } typedef struct { double x, y, z; } PP; // Point typedef struct { double a, b, c, d; } PL; // Plane double distPlP(PL *pl, PP *p) { double t = fabs(pl->a * p->x + pl->b * p->y + pl->c * p->z + pl->d); return t/sqrt(p->x * p->x + p->y * p->y + p->z * p->z); } PP p, q[305]; int N; int main() { int i, j, k; PP t; PL pl; double ans; N = in(); p.x = getdbl(), p.y = getdbl(), p.z = getdbl(); for (i = 0; i < N; i++) { q[i].x = getdbl(), q[i].y = getdbl(), q[i].z = getdbl(); } ans = 0, pl.d = 0; for (i = 0; i < N; i++) for (j = i+1; j < N; j++) for (k = j+1; k < N; k++) { t.x = (q[j].y-q[i].y) * (q[k].z-q[i].z) - (q[j].z-q[i].z) * (q[k].y-q[i].y); t.y = (q[j].z-q[i].z) * (q[k].x-q[i].x) - (q[j].x-q[i].x) * (q[k].z-q[i].z); t.z = (q[j].x-q[i].x) * (q[k].y-q[i].y) - (q[j].y-q[i].y) * (q[k].x-q[i].x); pl.a = p.x - q[i].x, pl.b = p.y - q[i].y, pl.c = p.z - q[i].z; ans += distPlP(&pl, &t); } printf("%.12lf\n", ans); return 0; }