5839Special Tetrahedron---hdu5839 (calculate geometry, find special tetrahedron number)

Source: Internet
Author: User

Title Link: http://acm.hdu.edu.cn/showproblem.php?pid=5839

Give you n three-dimensional point, and then beg this n each point can constitute how many special tetrahedron, special tetrahedron meet a two points;

1. At least four faces, etc.;

2. If only four edges are equal, then the remaining two edges are not adjacent;

The range of n is 300;

Violence enumerates the two points of one side of the tetrahedron, and then makes the distance between the other two points and the two points equal, judging whether the four points are coplanar;

And if it can constitute a tetrahedron to see if it is a positive tetrahedron, if it is a tetrahedron, then six edges will be able to enumerate one side, the result is part of the number of positive hexahedral/6; otherwise it is not equal to the pair of edges enumerated two times so to/2;

#include <iostream>#include<algorithm>#include<string.h>#include<stdio.h>#include<math.h>using namespacestd;#defineN 500#defineMet (A, b) memset (A, B, sizeof (a))#defineMoD 1000000007typedefLong LongLL;structpoint{intx, Y, z;};DoubleDist (Point A, point B)///find the distance between two points;{    DoubleAns = sqrt ((a.x-b.x) * (a.x-b.x) + (A.Y-B.Y) * (A.Y-B.Y) + (a.z-b.z) * (a.z-b.z)); returnans;}BOOLJudge (Point A, point B, point C, point D)///determine whether the four points are coplanar, and the Coplanar return is true;{point S1, S2, S3; s1.x= b.x-a.x; S1.y = B.Y-A.Y; S1.z = b.z-a.z; s2.x= c.x-a.x; S2.y = C.Y-A.Y; S2.z = c.z-a.z; s3.x= d.x-a.x; S3.y = D.Y-A.Y; S3.z = D.z-a.z; intAns = 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; returnAns = =0;}/*ans = value of the following determinant; s1.x s2.x s3.xs1.y s2.y s3.ys1.z s2.z s3.z*/intMain () {intT, T =1, N; scanf ("%d", &T);  while(t--) {point a[n]; scanf ("%d", &N);  for(intI=1; i<=n; i++) scanf (" %d%d%d", &a[i].x, &AMP;A[I].Y, &a[i].z); intANS1 =0, Ans2 =0;  for(intI=1; i<=n; i++)        {             for(intj=i+1; j<=n; J + +) {point t[n]; intCNT =0;  for(intk=1; k<=n; k++)                {                    if(K==i | | k==j)Continue; if(Dist (A[k], a[i])! = Dist (A[k], a[j]))Continue; T[cnt++] =A[k]; }                if(CNT <2)Continue;  for(intp=0; p<cnt; p++)                {                     for(intq=p+1; q<cnt; q++)                    {                        if(Judge (A[i], a[j], t[p], t[q]))Continue; if(Dist (A[i], t[p])! = Dist (T[q], a[i]))Continue; if(Dist (A[i], a[j]) = = Dist (T[p], t[q]) && Dist (A[i], a[j]) = =Dist (T[p], a[i])) ans1++;///number of positive tetrahedron;                        ElseAns2++;///number of tetrahedron with four sides equal;}}}} printf ("Case #%d:%d\n", t++, ans1/6+ ans2/2); }    return 0;}
View Code

5839Special Tetrahedron---hdu5839 (calculate geometry, find 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.