#include #include #include #include #include #include using namespace std; typedef struct { double x; double y; double z; } Point; Point subtract(Point, Point);; Point cross_product(Point, Point); double calc(Point, Point, Point); Point p; int main() { int n; cin >> n; int x, y, z; vector q(n); cin >> p.x >> p.y >> p.z; for (int i = 0; i < n; i++) { cin >> q[i].x >> q[i].y >> q[i].z; } Point ab, ac; double ans = 0.0; for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { for (int k = j + 1; k < n; k++) { ans += calc(q[i], q[j], q[k]); } } } printf("%.10f\n", ans); return 0; } Point subtract(Point a, Point b) { Point c; c.x = a.x - b.x; c.y = a.y - b.y; c.z = a.z - b.z; return c; } Point cross_product(Point a, Point b) { Point c; c.x = a.y * b.z - a.z * b.y; c.y = a.z * b.x - a.x * b.z; c.z = a.x * b.y - a.y * b.x; return c; } double calc(Point p1, Point p2, Point p3) { Point p12, p13, cross; p12 = subtract(p2, p1); p13 = subtract(p3, p1); cross = cross_product(p12, p13); double d; d = -1.0 *(cross.x * p1.x + cross.y * p1.y + cross.z * p1.z); return abs(cross.x * p.x + cross.y * p.y + cross.z * p.z + d) / sqrt(cross.x * cross.x + cross.y * cross.y + cross.z * cross.z); }