1265. four-point common reference time limit: 1 second space limit: 65536 kb score: 0 gives four points in three-dimensional space (points and points are not the same ), determine whether the four vertices are in the same plane (the four vertices are collocated ). If it is a common area, "yes" is output; otherwise, "no" is output ". Input
Row 1st: A number t, indicating the number of input tests (1 <= T <= 1000) 2nd-4 t + 1 rows: 4 rows in each row indicates a group of data, the three numbers in each row, x, y, and z, indicate the coordinates of the point (-1000 <= x, y, z <= 1000 ).
Output
T rows are output. If yes is output, no is output ".
Input example
11 2 02 3 04 0 00 0 0
Output example
Yes
// Train of thought: create three vectors from four points to form a determinant. If the value of the determinant is 0, it is a common area.
How to calculate the level 3 determinant :.[28]
#include<cstdio>struct point{ int x,y,z;}p[1001];int main(){ int t,i,ans; point s1,s2,s3; scanf("%d",&t); while(t--) { for(i=0;i<4;i++) scanf("%d%d%d",&p[i].x,&p[i].y,&p[i].z); s1.x=p[1].x-p[0].x;s1.y=p[1].y-p[0].y;s1.z=p[1].z-p[0].z; s2.x=p[2].x-p[0].x;s2.y=p[2].y-p[0].y;s2.z=p[2].z-p[0].z; s3.x=p[3].x-p[0].x;s3.y=p[3].y-p[0].y;s3.z=p[3].z-p[0].z; ans=s1.x*s2.y*s3.z+s1.y*s2.z*s3.x+s1.z*s2.x*s3.y-s1.z*s2.y*s3.x-s1.x*s2.z*s3.y-s1.y*s2.x*s3.z; if(ans==0) printf("Yes\n"); else printf("No\n"); } return 0;}
Determine four common points