uva 10733 The Colored Cubes<polya定理>

链接:http://uva.onlinejudge.org/external/107/10733.pdf

题意: N 种颜色可以涂成多少种立方体~

思路: 使正六面体保持不变的运动群总共有:

1.不变置换(1)(2)(3)(4)(5)(6), 共1个;

2.沿对面中心轴旋转 90度, 270度 (1)(2345)(6), (1)(5432)(6) 同类共 6个;

3.沿对面中心轴旋转 180度 (1)(24)(35)(6), 同类共 3个;

4.沿对角线轴旋转 120度, 240度 (152)(346), (251)(643) 同类共 8个;

5.沿对边中点轴旋转 180度 (16)(25)(43) 同类共 6个;

 1 #include <cstdio>
 2 #include <iostream>
 3 using namespace std;
 4 int N, M;
 5 typedef long long LL;
 6 LL P_M(int a, int b )
 7 {
 8     LL res=1,t=a;
 9     while(b){
10         if(b&1)res*=t;
11         t*=t;
12         b>>=1;
13     }
14     return res;
15 }
16 
17 int main()
18 {
19     int n;
20     while(scanf("%d",&n)!=EOF&&n)
21     {
22         LL ans=0;
23         ans += P_M(n,6);
24         ans += 3*P_M(n,4);
25         ans += 12*P_M(n,3);
26         ans += 8*P_M(n,2);
27         ans /= 24;
28         printf("%lld
",ans);
29 
30     }
31 }
View Code
原文地址:https://www.cnblogs.com/jian1573/p/3234889.html