标签:
Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 175 Accepted Submission(s): 64
#include<cstdio> #include<cstring> #include<iostream> #include<algorithm> #include<cmath> using namespace std; struct point { double x,y,z; }a[203]; int n,T,ans,ans2,tot,tmp[203]; double d[203][203]; double qdis(int i,int j) { return sqrt((a[i].x-a[j].x)*(a[i].x-a[j].x)+(a[i].y-a[j].y)*(a[i].y-a[j].y)+(a[i].z-a[j].z)*(a[i].z-a[j].z)); } point operator -(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 operator +(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 operator /(point A,double B) { point C; C.x=A.x/B; C.y=A.y/B; C.z=A.z/B; return C; } double operator *(point A,point B) { return A.x*B.x+A.y*B.y+A.z*B.z; } bool check(point A,point B) { if(abs(A*B)<0.00000001)return true; else return false; } bool check2(point A,point B) { if(abs(A.x-B.x)<0.00000001&&abs(A.y-B.y)<0.000000001&&abs(A.z-B.z)<0.000000001) return false; return true; } bool check3(int i,int j,int k,int l) { if(d[i][j]==d[l][k]&&d[i][l]==d[i][j]) return true; return false; } int main() { cin>>T; for(int p=1;p<=T;p++) { ans2=ans=0; scanf("%d",&n); for(int i=1;i<=n;i++) { scanf("%lf%lf%lf",&a[i].x,&a[i].y,&a[i].z); } for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) { d[i][j]=qdis(i,j); } /*for(int i=1;i<=n;i++) { for(int j=1;j<=n;j++) cout<<d[i][j]<<" "; cout<<endl; }*/ for(int i=2;i<=n;i++) { for(int j=1;j<i;j++) { tot=0; for(int k=1;k<=n;k++) { if(k!=i&&k!=j) { if(check((a[i]+a[j])/2-a[k],a[i]-a[j])) { tmp[++tot]=k; } } } //cout<<tot<<": "; ///for(int k=1;k<=tot;k++) //cout<<tmp[k]<<" ";cout<<endl; for(int k=2;k<=tot;k++) for(int l=1;l<k;l++) { if(abs(d[tmp[k]][i]-d[tmp[l]][i])<0.000001) { if(check2((a[tmp[k]]+a[tmp[l]])/2,(a[i]+a[j])/2)) { ans++; if(check3(tmp[k],tmp[l],i,j)) ans2++; } } } } } ans=ans-(ans2/6)*4; cout<<"Case #"<<p<<": "<<ans/2<<endl; } return 0; }
hdu 5839 Special Tetrahedron 计算几何 求特殊四面体个数
标签:
原文地址:http://www.cnblogs.com/haze/p/5771202.html