HDU 5839 Special tetrahedron calculating geometry for special tetrahedron number

Source: Internet
Author: User

Special Tetrahedron

Time limit:4000/2000 MS (java/others) Memory limit:65536/65536 K (java/others)
Total submission (s): 175 Accepted Submission (s): 64


Problem Descriptiongiven n points which is in three-dimensional space (without repetition).

Please find out how many distinct special tetrahedron among them. A tetrahedron is called special tetrahedron if it has a following characters.

1. At least four edges has the same length.

2. If it has exactly four edges of the same length, the other and the edges is not adjacent.

Inputintput contains multiple test cases.

The first line was an integerT,1≤t≤ , the number of test cases.

Each case begins with an integern(n≤) , indicating the number of the points.

The nextNLines contains three integersxi,yi,zi , ( Span id= "mathjax-span-40" class= "Mo" >−2000 ≤ Xi,yi,z i≤ 2000) , representing the coordinates of the ith point.

Outputfor each test case,output a line which contains ' case #x: Y ', X represents the Xth test (starting from one), Y is the Nu Mber of special tetrahedron.

Sample Input240 0 00 1 11 0 11 1 090 0 00 0 21 1 1-1-1 11-1 1-1 1 11 1 01 0 10 1 1

Sample outputcase #1:1Case #2:6

Authoruestc

SOURCE2016 Chinese college Students Program Design Competition-Network tryouts test instructions to find at least four sides equal to the number of tetrahedron N^3 enumeration with the midpoint of the two point and the line perpendicular to the point mm^2 determine whether the final delete duplicates
#include <cstdio>#include<cstring>#include<iostream>#include<algorithm>#include<cmath>using namespacestd;structpoint{Doublex, Y, Z;} a[203];intn,t,ans,ans2,tot,tmp[203];Doubled[203][203];DoubleQdis (intIintj) {    returnsqrt ((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));} Pointoperator-(Point A,point B) {point C; c.x=a.x-b.x; C.y=a.y-b.y; C.z=a.z-b.z; returnC;} Pointoperator+(Point A,point B) {point C; c.x=a.x+b.x; C.y=a.y+b.y; C.z=a.z+b.z; returnC;} Pointoperator/(Point A,DoubleB)    {Point C; c.x=a.x/B; C.y=a.y/B; C.z=a.z/C; returnC;}Double operator*(Point A,point B) {returna.x*b.x+a.y*b.y+a.z*b.z;}BOOLCheck (point a,point B) {if(ABS (A*B) <0.00000001)return true; Else return false;}BOOLCheck2 (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;}BOOLCheck3 (intIintJintKintl) {    if(d[i][j]==d[l][k]&&d[i][l]==D[i][j])return true; return false;}intMain () {CIN>>u;  for(intp=1;p <=t;p++) {Ans2=ans=0; scanf ("%d",&N);  for(intI=1; i<=n;i++) {scanf ("%LF%LF%LF",&a[i].x,&a[i].y,&a[i].z); }         for(intI=1; i<=n;i++)         for(intj=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(intI=2; i<=n;i++)        {             for(intj=1; j<i;j++) {tot=0;  for(intk=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;}

M

HDU 5839 Special tetrahedron calculating geometry for special tetrahedron number

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.