标签:
暴力水过,数据水。
#pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> #include<vector> #include<map> #include<set> #include<queue> #include<stack> #include<iostream> using namespace std; typedef long long LL; const double pi=acos(-1.0); void File() { freopen("D:\\in.txt","r",stdin); freopen("D:\\out.txt","w",stdout); } template <class T> inline void read(T &x) { char c = getchar(); x = 0;while(!isdigit(c)) c = getchar(); while(isdigit(c)) { x = x * 10 + c - ‘0‘; c = getchar(); } } const int maxn=300; struct point { int x,y,z; }p[maxn]; int T,n,len[10]; bool isonLine(int i,int j,int k) { int ax=p[j].x-p[i].x, ay=p[j].y-p[i].y, az=p[j].z-p[i].z; int bx=p[k].x-p[i].x, by=p[k].y-p[i].y, bz=p[k].z-p[i].z; int tx=(ay*bz-az*by), ty=(az*bx-ax*bz), tz=(ax*by-ay*bx); int ans=tx*tx+ty*ty+tz*tz; if(ans==0)return true; return false; } int dis(int i,int j) { int x=p[j].x-p[i].x, y=p[j].y-p[i].y, z=p[j].z-p[i].z; return x*x+y*y+z*z; } bool isonFace(int i,int j,int k,int l) { point s1,s2,s3; s1.x=p[j].x-p[i].x;s1.y=p[j].y-p[i].y;s1.z=p[j].z-p[i].z; s2.x=p[k].x-p[i].x;s2.y=p[k].y-p[i].y;s2.z=p[k].z-p[i].z; s3.x=p[l].x-p[i].x;s3.y=p[l].y-p[i].y;s3.z=p[l].z-p[i].z; int 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) return true; return false; } int main() { scanf("%d",&T); int cas=1; while(T--) { scanf("%d",&n); for(int i=1;i<=n;i++) scanf("%d%d%d",&p[i].x,&p[i].y,&p[i].z); int ans=0; for(int i=1;i<=n;i++) { for(int j=i+1;j<=n;j++) { for(int k=j+1;k<=n;k++) { if(isonLine(i,j,k)) continue; len[1]=dis(i,j); len[2]=dis(i,k); len[3]=dis(j,k); int f; if(len[1]==len[2]&&len[1]==len[3]) f=len[1]; else if(len[1]==len[2]) f=len[1]; else if(len[1]==len[3]) f=len[1]; else if(len[2]==len[3]) f=len[2]; else continue; for(int s=k+1;s<=n;s++) { if(isonFace(i,j,k,s)) continue; len[4]=dis(i,s); len[5]=dis(j,s); len[6]=dis(k,s); int sum=0; for(int d=1;d<=6;d++) if(len[d]==f) sum++; if(sum<4) continue; else if(sum>=5) ans++; else { int id1,id2,flag=0; for(int d=1;d<=6;d++) { if(len[d]==f) continue; if(flag==0) id1=d,flag=1; else id2=d; } if( (id1==1&&id2==6) || (id1==2&&id2==5) || (id1==3&&id2==4) ) ans++; } } } } } printf("Case #%d: %d\n",cas++,ans); } return 0; }
标签:
原文地址:http://www.cnblogs.com/zufezzt/p/5782067.html