uva10601 - Cubes 正方体置换

 

You are given 12 rods of equal length. Each of them is coloredin certain color. Your task is to determine in how many different ways one canconstruct a cube using these rods as edges. Two cubes are considered equal ifone of them could be rotated and put next to the other, so that thecorresponding edges of the two cubes are equally colored.

 

Input

The first line of input contains T (1≤T≤60), thenumber of test cases. Then T test cases follow. Each test case consists of oneline containing 12 integers. Each of them denotes the color of thecorresponding rod. The colors are numbers between 1 and 6.

 

Output

The output for one test consists of one integer on a line -the number of ways one can construct a cube with the described properties.

 

Sample Input

Sample Output

3

1 2 2 2 2 2 2 2 2 2 2 2

1 1 2 2 2 2 2 2 2 2 2 2

1 1 2 2 3 3 4 4 5 5 6 6

1

5

312120


  正方体的12条棱,给你12个颜色(1到6,可重复),问有多少种正方体,旋转相同算一种。

  一个正方体有24种置换(以每个面为顶都有4种),所以最后答案除以24。

  1.静止不动,12个循环,每个长度为1。

  2.以面心旋转90,180,270。旋转90和270的时候有6个循环,每个循环节长度为4。180的时候3个循环,循环节长度为2。

  3.以对立顶点为轴旋转120,240,4组对角顶点,每组有120和240度,所以8个循环,循环节长度3。

  4.以对立棱的中点为轴旋转180,6组对立棱,6个循环,两个棱的循环节是1,剩下的循环节是2。

  这就是正方体的全部置换情况了,其它组合情况也都和这里的情况等价。

#include<iostream>
#include<algorithm>
#include<queue>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<set>
#include<map>
#define INF 0x3f3f3f3f
#define MAXN 2000010
#define MAXM 1500
#define MOD 1000000007
#define MAXNODE 8*MAXN
#define eps 1e-9
using namespace std;
typedef long long LL;
int T,cnt[10];
LL fac(int n){
    LL ret=1;
    for(int i=2;i<=n;i++) ret*=i;
    return ret;
}
int main(){
    freopen("in.txt","r",stdin);
    scanf("%d",&T);
    while(T--){
        memset(cnt,0,sizeof(cnt));
        int t;
        for(int i=0;i<12;i++){
            scanf("%d",&t);
            cnt[t]++;
        }
        LL ans=fac(12);     //不旋转
        for(int i=1;i<=6;i++) ans/=fac(cnt[i]);
        //绕面心旋转90,270,循环节是4
        int flag=1;
        for(int i=1;i<=6;i++){
            if(cnt[i]%4){
                flag=0;
                break;
            }
        }
        if(flag){
            LL t=fac(3);
            for(int i=1;i<=6;i++) t/=fac(cnt[i]/4);
            ans+=3*2*t;
        }
        //绕面心旋转180,循环节是2
        flag=1;
        for(int i=1;i<=6;i++){
            if(cnt[i]%2){
                flag=0;
                break;
            }
        }
        if(flag){
            LL t=fac(6);
            for(int i=1;i<=6;i++) t/=fac(cnt[i]/2);
            ans+=3*t;
        }
        //以对角顶点为轴旋转120,240,循环节是3
        flag=1;
        for(int i=1;i<=6;i++){
            if(cnt[i]%3){
                flag=0;
                break;
            }
        }
        if(flag){
            LL t=fac(4);
            for(int i=1;i<=6;i++) t/=fac(cnt[i]/3);
            ans+=4*2*t;
        }
        //以对立的棱的中点为轴旋转180,除了那两条棱外循环节是2,两条棱循环节是1
        for(int i=1;i<=6;i++) if(cnt[i]>0){
            cnt[i]--;
            for(int j=0;j<=6;j++) if(cnt[j]>0){
                cnt[j]--;
                flag=1;
                for(int k=1;k<=6;k++){
                    if(cnt[k]%2){
                        flag=0;
                        break;
                    }
                }
                if(flag){
                    LL t=fac(5);
                    for(int k=1;k<=6;k++) t/=fac(cnt[k]/2);
                    ans+=6*t;
                }
                cnt[j]++;
            }
            cnt[i]++;
        }
        printf("%d\n",ans/24);
    }
    return 0;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Marching Cubes算法是一种常用的三维数据表面重建算法。它可以将一个数据集转化为连续的多边形网格模型。 在三维数据中,每个素的值表示其在某一属性上的特征,如密度、压力等。Marching Cubes算法首先将整个数据集划分为无数个小立方,每个小立方包含8个顶点。然后根据每个小立方顶点所代表的属性值与事先设定的阈值进行比较,确定该顶点是否在表面上。若在表面上,就将相应顶点连接起来组成一个面,并将该面连接到整个网格模型上。 得到的多边形网格模型可以用于可视化、仿真和分析等应用。Marching Cubes算法具有简单、高效的特点,适用于各种不规则的三维数据集。它广泛应用于医学图像处理、地质勘探、计算机动画等领域。 然而,Marching Cubes算法也存在一些限制。首先,它在重建过程中产生的多边形可能存在不连续性和拓扑错误。为了解决这个问题,后续研究提出了一些改进算法,如Dual Marching Cubes和Extended Marching Cubes。其次,Marching Cubes算法对数据集的分辨率要求较高,对于过于细致的结构可能无法很好地重建。 总的来说,Marching Cubes算法在三维数据表面重建领域具有重要的应用价值,其简单、高效的特点使其成为一种常用的算法。随着相关技术的不断发展,对Marching Cubes算法的改进和优化将进一步推动其在各个领域的应用。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值