hdu 4633 Who's Aunt Zhang(polya+逆元)

本文探讨了张阿姨为送给刘老师的魔方进行染色的问题,利用Polya定理计算不同颜色组合的数量,并给出了具体的计算过程及代码实现。

Who's Aunt Zhang

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 125    Accepted Submission(s): 108

Problem Description
Aunt Zhang, well known as 张阿姨, is a fan of Rubik’s cube. One day she buys a new one and would like to color it as a gift to send to Teacher Liu, well known as 刘老师. As Aunt Zhang is so ingenuity, she can color all the cube’s points, edges and faces with K different color. Now Aunt Zhang wants to know how many different cubes she can get. Two cubes are considered as the same if and only if one can change to another ONLY by rotating the WHOLE cube. Note that every face of Rubik’s cube is consists of nine small faces. Aunt Zhang can color arbitrary color as she like which means that she doesn’t need to color the nine small faces with same color in a big face. You can assume that Aunt Zhang has 74 different elements to color. (8 points + 12 edges + 9*6=54 small faces)
 
Input
The first line of the date is an integer T, which is the number of the text cases. Then T cases follow, each case contains one integer K, which is the number of colors. T<=100, K<=100.
 
Output
For each case, you should output the number of different cubes. Give your answer modulo 10007.
 
Sample Input
3 1 2 3
 
Sample Output
Case 1: 1 Case 2: 1330 Case 3: 9505
 
Source
 
Recommend
zhuyuanchen520
 
 
/*
本体明显的polya的应用.     G为置换群总数,c(gi)为群gi的循环节。。
  
步骤:               

先求置换种类,接着再手动画图算出循环节!!!

 

本题模型共有4大类置换,共24种:

1. 不做任何旋转 K ^ (54 + 12 + 8)

 

2. 绕相对面中心的轴转

1) 90度 K ^ (15 + 3 + 2) * 3

1) 180度 K ^ (28 + 6 + 4) * 3

1) 270度 K ^ (15 + 3 + 2) * 3

3. 绕相对棱中心的轴转

1) 180度 K ^ (27 + 7 + 4) * 6

4. 绕相对顶点的轴转

1) 120度 K ^ (18 + 4 + 4) * 4

1) 240度 K ^ (18 + 4 + 4) * 4

 

 1 #include <iostream>
 2 #include<stdio.h>
 3 #include<string.h> 
 4 #include <cstdio>
 5 #include <algorithm>
 6 #include <cmath>
 7 #include <cstring>
 8 using namespace std;
 9 const int mo=10007;
10 
11 int q(int a,int b)
12 {
13     int ans=1;
14     a%=mo;
15     while(b)
16     {
17         if(b&1)
18         {
19             ans=ans*a%mo;
20             b--;
21         }
22         b>>=1;
23         a=a*a%mo;
24     }
25     return ans;
26 }
27 
28 int main()
29 {
30     int ca,i,j,T,k;
31     scanf("%d",&T);
32     for(ca=1;ca<=T;ca++)
33     {
34         scanf("%d",&k);
35         int ans=0;
36         ans+=q(k,74);//不转 
37         
38         ans+=q(k,20)*3+q(k,20)*3;//面面90与270度;         
39         ans+=q(k,38)*3;//面面180度; 
40         
41         ans+=q(k,38)*6;//対棱180;
42         
43         ans+=q(k,26)*4+ q(k,26)*4;//对顶;
44         
45         ans%=mo;
46         ans*=q(24,mo-2);
47         ans%=mo;
48         
49         printf("Case %d: ",ca); 
50         printf("%d\n",ans); 
51          
52     }
53     
54 }
View Code

 

 

转载于:https://www.cnblogs.com/skykill/p/3233488.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值