• (四面体)CCPC网络赛 HDU5839 Special Tetrahedron


     1 CCPC网络赛 HDU5839 Special Tetrahedron
     2 题意:n个点,选四个出来组成四面体,要符合四面体至少四条边相等,若四条边相等则剩下两条边不相邻,求个数
     3 思路:枚举四面体上一条线,再找到该线两个端点相等的点,放在一个集合里面。
     4 要符合条件的话,则该集合里面找两个点,并且要判断一下。
     5 注意,普通四面体会被重复计算两次,正四面体会重复计算六次
     6 
     7 
     8 #include <bits/stdc++.h>
     9 using namespace std;
    10 #define LL long long
    11 const double inf = 123456789012345.0;
    12 const LL MOD =100000000LL;
    13 const int N =210;
    14 #define clc(a,b) memset(a,b,sizeof(a))
    15 const double eps = 1e-7;
    16 void fre() {freopen("in.txt","r",stdin);}
    17 void freout() {freopen("out.txt","w",stdout);}
    18 inline int read() {int x=0,f=1;char ch=getchar();while(ch>'9'||ch<'0') {if(ch=='-') f=-1; ch=getchar();}while(ch>='0'&&ch<='9') {x=x*10+ch-'0';ch=getchar();}return x*f;}
    19 
    20 struct Point {
    21     double x,y,z;
    22     Point() {}
    23     Point(LL _x,LL _y,LL _z):x(_x),y(_y),z(_z) {}
    24     Point operator + (const Point &t) const {
    25         return Point(x+t.x,y+t.y,z+t.z);
    26     }
    27     Point operator -(const Point &t) const {
    28         return Point(x-t.x,y-t.y,z-t.z);
    29     }
    30     Point operator *(const Point &t) const {
    31         return Point(y*t.z-z*t.y,z*t.x-x*t.z,x*t.y-y*t.x);
    32     }
    33     double operator ^(const Point &t) const {
    34         return x*t.x+y*t.y+z*t.z;
    35     }
    36     double len2(){
    37         return x*x+y*y+z*z;
    38     }
    39 } p[N];
    40 
    41 bool check(Point a,Point b,Point c,Point d) {
    42     return (((a-b)*(a-c))^(a-d))==0.0;
    43 }
    44 
    45 int l[210];
    46 int main() {
    47     int T;
    48     scanf("%d",&T);
    49     for(int cas=1; cas<=T; cas++) {
    50         int n,cnt;
    51         int ans=0,tem=0;
    52         scanf("%d",&n);
    53         for(int i=1; i<=n; i++) scanf("%lf%lf%lf",&p[i].x,&p[i].y,&p[i].z);
    54         for(int i=1; i<n; i++) {
    55             for(int j=i+1; j<=n; j++) {
    56                 cnt=0;
    57                 for(int k=1; k<=n; k++) {
    58                     if(k==i||k==j) continue;
    59                     Point p1,p2;
    60                     p1=p[k]-p[i];
    61                     p2=p[k]-p[j];
    62                     if(p1.len2()==p2.len2()) {
    63                         l[cnt++]=k;
    64                     }
    65                 }
    66                 for(int k=0; k<cnt-1; k++) {
    67                     for(int h=k+1; h<cnt; h++) {
    68                         Point p1=p[l[h]]-p[i],p2=p[l[k]]-p[i];
    69                         if(p1.len2()!=p2.len2()) continue;
    70                         if(check(p[i],p[j],p[l[k]],p[l[h]])) continue;
    71                         ans++;
    72                         Point p3=p[l[k]]-p[l[h]];
    73                         Point p4=p[i]-p[j];
    74                         if(p1.len2()==p3.len2()&&p4.len2()==p3.len2())
    75                             tem++;
    76                     }
    77                 }
    78             }
    79         }
    80         ans/=2;
    81         ans=ans-2*tem/6;
    82         printf("Case #%d: ",cas);
    83         printf("%d
    ",ans);
    84     }
    85     return 0;
    86 }
  • 相关阅读:
    ZOJ 2601 Warehouse Keeper
    POJ 2175 Evacuation Plan
    NYIST 1108 最低的惩罚
    二进制 与 十进制 互转
    javascript学习(9)——[设计模式]单例
    2013 Changsha Regional 一样的木板一样的气球
    muduo简化(1):Reactor的关键结构
    Oracle 11g New 热补丁
    跳转表实例
    [置顶] android 心跳包的分析
  • 原文地址:https://www.cnblogs.com/ITUPC/p/5772975.html
Copyright © 2020-2023  润新知