[51nod1265]四点共面
解题关键:此题有多种解法
三条直线组成的矩阵delta为0,则共面,否则,不共面 Gauss消元法
1 #include<bits/stdc++.h> 2 using namespace std; 3 typedef long long ll; 4 struct tpoint{ 5 double x,y,z; 6 tpoint operator-(const tpoint &p)const{ 7 tpoint q; 8 q.x=x-p.x; 9 q.y=y-p.y; 10 q.z=z-p.z; 11 return q; 12 } 13 }p[4]; 14 int delta(){ 15 tpoint a,b,c; 16 a=p[0]-p[1]; 17 b=p[0]-p[2]; 18 c=p[0]-p[3]; 19 return a.x*b.y*c.z+a.y*b.z*c.x+a.z*b.x*c.y-a.z*b.y*c.x-a.y*b.x*c.z-a.x*b.z*c.y; 20 } 21 int main(){ 22 int t; 23 cin>>t; 24 while(t--){ 25 for(int i=0;i<4;i++) cin>>p[i].x>>p[i].y>>p[i].z; 26 if(delta()==0) cout<<"Yes\n"; 27 else cout<<"No\n"; 28 } 29 return 0; 30 }