12,654-point Coplanar base time limit: 1 second space limit: 131072 KB score: 0 Difficulty: Basic problem collection focus on the three-dimensional space on the four points (the point and the location of the point are not the same), to determine whether the 4 points in the same plane (4 points collinear also counted coplanar). If the coplanar, output "Yes", otherwise output "No". Input
Line 1th: A number T, indicating the number of tests entered (1 <= t <= 1000) 第2-4 T + 1 lines: 4 rows per line represents a set of data, 3 numbers per row, x, Y, Z, indicating the location coordinates of the point ( -1000 <= x, y, z <= 1000).
Output
Outputs a total of t lines, or outputs "No" if the coplanar output is "Yes".
Input example
11 2 02 3 04 0 00 0 0
Output example
Yes
Li Tao(topic Provider)
Click to open link
#include <iostream> #include <algorithm> #include <stdio.h> #include <string.h> #include < stdlib.h> #include <math.h> #define EPS 1e-8#define Zero (x) (((x) >0? ( x):-(x)) <eps) using the namespace Std;struct point3{double x, y, z;}; struct line3{point3 A, b;}; struct plane3{point3 a,b,c;}; Point3 Xmult (Point3 U,point3 v) {POINT3 ret; Ret.x = u.y*v.z-v.y*u.z; Ret.y = u.z*v.x-u.x*v.z; Ret.z = u.x*v.y-u.y*v.x; return ret;} Point3 subt (Point3 U,point3 v) {POINT3 ret; Ret.x = u.x-v.x; Ret.y = U.Y-V.Y; Ret.z = u.z-v.z; return ret;} Point3 Pvec (Point3 a,point3 b,point3 c) {return Xmult (Subt (A, B), Subt (B,c));} Double Dmult (point3 U,point3 v) {return u.x*v.x + u.y*v.y + u.z*v.z;} int Dots_onplane (point3 a,point3 b,point3 c,point3 d) {return zero (Dmult (Pvec), A,b,c (SUBT)));} int main () {Point3 a[4]; int T; scanf ("%d", &t); while (t--) {for (int i=0;i<4;i++) {scanf ("%lf%lf%lf", &a[i].x,&A[I].Y,&A[I].Z); } int flag = Dots_onplane (a[0],a[1],a[2],a[3]); if (flag = = 1) {printf ("yes\n"); }else{printf ("no\n"); }} return 0;}
Copyright NOTICE: This article is the original blogger article, if you have special needs, please contact Bo Master qq:793977586.
51nod 12,654-point Coplanar (four points in total face)