Who's Aunt Zhang

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

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计数的题目。

但是本题有74个元素,

总共的变换数数24种。

数起来很麻烦,数据很大。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。

于是我用代码怒搞之。

写代码找不动点。。。。共24种变换,24种都可以通过多次右旋和上旋得到。。。

300多行代码,,,,,终于找到不动点个数了。。。。。。

附上源代码,。包括找不动点。。

找出来可以直接用公式写的,就没有优化了

 /*
* Author:kuangbin
* 1002.cpp
*/ #include <stdio.h>
#include <algorithm>
#include <string.h>
#include <iostream>
#include <map>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <math.h>
using namespace std;
const int MOD = ;
long long pow_m(long long a,long long n)
{
long long ret = ;
long long tmp = a%MOD;
while(n)
{
if(n&)
{
ret *= tmp;
ret %=MOD;
}
tmp *= tmp;
tmp %=MOD;
n >>= ;
}
return ret;
}
//求ax = 1( mod m) 的x值,就是逆元(0<a<m)
long long inv(long long a,long long m)
{
if(a == )return ;
return inv(m%a,m)*(m-m/a)%m;
} int b[];
int c[]; void rr()
{
for(int i = ;i <= ;i++)
c[i] = b[i];
for(int i = ;i <= ;i++)
b[i+] = c[i];
for(int i = ;i <= ;i++)
b[i] = c[+i];
b[] = c[];
b[] = c[];
b[] = c[];
b[] = c[];
b[] = c[];
b[] = c[];
b[] = c[];
b[] = c[];
b[] = c[]; b[] = c[];
b[] = c[];
b[] = c[];
b[] = c[];
b[] = c[];
b[] = c[];
b[] = c[];
b[] = c[];
b[] = c[]; }
void up()
{
for(int i = ;i <= ;i++)
c[i] = b[i];
for(int i = ;i <= ;i++)
b[i] = c[+i];
for(int i = ;i <= ;i++)
b[i] = c[i-];
for(int i = ;i <= ;i++)
b[i] = c[-i];
for(int i = ;i <= ;i++)
b[i] = c[-i]; b[] = c[];
b[] = c[];
b[] = c[];
b[] = c[];
b[] = c[];
b[] = c[];
b[] = c[];
b[] = c[];
b[] = c[]; b[] = c[];
b[] = c[];
b[] = c[];
b[] = c[];
b[] = c[];
b[] = c[];
b[] = c[];
b[] = c[];
b[] = c[]; } bool used[]; int calc()
{
memset(used,false,sizeof(used)); int ret = ;
for(int i = ;i <= ;i++)
if(!used[i])
{
ret++;
int tmp = i;
while(!used[tmp])
{
used[tmp] = true;
tmp = b[tmp];
}
}
return ret; } void rr2()
{
for(int i = ;i <= ;i++)
c[i] = b[i];
b[] = c[];
for(int i = ;i <= ;i++)
b[i] = c[i-];
b[] = c[];
for(int i = ;i <= ;i++)
b[i] = c[i-];
b[] = c[];
for(int i = ;i <= ;i++)
b[i] = c[i-];
}
void up2()
{
for(int i = ;i <= ;i++)
c[i] = b[i];
b[] = c[];
b[] = c[];
b[] = c[];
b[] = c[];
b[] = c[];
b[] = c[];
b[] = c[];
b[] = c[];
b[] = c[];
b[] = c[];
b[] = c[];
b[] = c[];
}
int calc2()
{
memset(used,false,sizeof(used)); int ret = ;
for(int i = ;i <= ;i++)
if(!used[i])
{
ret++;
int tmp = i;
while(!used[tmp])
{
used[tmp] = true;
tmp = b[tmp];
}
}
return ret; } void rr3()
{
for(int i = ;i <= ;i++)
c[i] = b[i];
b[] = c[];
for(int i = ;i <= ;i++)
b[i] = c[i-];
b[] = c[];
for(int i = ;i <= ;i++)
b[i] = c[i-];
}
void up3()
{
for(int i = ;i <= ;i++)
c[i] = b[i];
b[]=c[];
b[]=c[];
b[]=c[];
b[]=c[];
b[]=c[];
b[]=c[];
b[]=c[];
b[]=c[];
}
int calc3()
{
memset(used,false,sizeof(used)); int ret = ;
for(int i = ;i <= ;i++)
if(!used[i])
{
ret++;
int tmp = i;
while(!used[tmp])
{
used[tmp] = true;
tmp = b[tmp];
}
}
return ret; }
int num1[];
int num2[];
int num3[];
int num[];
int main()
{
//freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
int cnt = ;
for(int i = ;i < ;i++)
for(int j = ;j < ;j++)
{
for(int x = ;x <= ;x++)
b[x] = x;
for(int x = ;x < i;x++)
up();
for(int x = ;x < j;x++)
rr();
num1[cnt++]=calc();
}
for(int x = ;x <= ;x++)
b[x] = x;
rr();
for(int i = ;i < ;i++)
{
num1[cnt++]=calc();
up();
}
for(int x = ;x <= ;x++)
b[x] = x;
rr();
rr();
rr();
for(int i = ;i < ;i++)
{
num1[cnt++]=calc();
up();
}
cnt = ;
for(int i = ;i < ;i++)
for(int j = ;j < ;j++)
{
for(int x = ;x <= ;x++)
b[x] = x;
for(int x = ;x < i;x++)
up2();
for(int x = ;x < j;x++)
rr2();
num2[cnt++]=calc2();
//printf("%d\n",calc2());
} for(int x = ;x <= ;x++)
b[x] = x;
rr2();
for(int i = ;i < ;i++)
{
num2[cnt++]=calc2();
up2();
}
for(int x = ;x <= ;x++)
b[x] = x;
rr2();
rr2();
rr2();
for(int i = ;i < ;i++)
{
num2[cnt++]=calc2();
up2();
}
cnt = ;
for(int i = ;i < ;i++)
for(int j = ;j < ;j++)
{
for(int x = ;x <= ;x++)
b[x] = x;
for(int x = ;x < i;x++)
up3();
for(int x = ;x < j;x++)
rr3();
num3[cnt++]=calc3();
//printf("%d\n",calc3());
}
for(int x = ;x <= ;x++)
b[x] = x;
rr3();
for(int i = ;i < ;i++)
{
num3[cnt++]=calc3();
up3();
}
for(int x = ;x <= ;x++)
b[x] = x;
rr3();
rr3();
rr3();
for(int i = ;i < ;i++)
{
num3[cnt++]=calc3();
up3();
}
for(int i = ;i < ;i++)
num[i] = num1[i]+num2[i]+num3[i];
//for(int i = 0;i <24;i++)
// printf("%d\n",num[i]);
int T;
scanf("%d",&T);
int n ;
int iCase = ;
while(T--)
{
iCase++;
scanf("%d",&n);
int ans = ; for(int i = ;i < ;i++)
{
ans += pow_m(n,num[i]);
ans %=MOD;
}
ans *= inv(,MOD);
ans %=MOD;
printf("Case %d: %d\n",iCase,ans);
}
return ;
}

HDU 4633 Who's Aunt Zhang (2013多校4 1002 polya计数)的更多相关文章

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

    Who's Aunt Zhang Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) ...

  2. HDU 4633 Who's Aunt Zhang(polay计数)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4633 题意:有下面一个魔方.有K种颜色.可以为顶点.边.面(每个面有9个小面)染色.两种染色算作一种当 ...

  3. HDU 4633 Who's Aunt Zhang (Polya定理+快速幂)

    题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=4633 典型的Polya定理: 思路:根据Burnside引理,等价类个数等于所有的置换群中的不动点的个 ...

  4. HDU 4633 Who's Aunt Zhang ★(Polya定理 + 除法取模)

    题意 用K个颜色给魔方染色,魔方只能整体旋转并且旋转重合的方案算一种,求一共有多少不同的染色方案. 思路 经典的Polya应用,记住正六面体的置换群就可以了,魔方就是每个大面变成9个小面了而已: 本题 ...

  5. HDU 4667 Building Fence(2013多校7 1002题 计算几何,凸包,圆和三角形)

    Building Fence Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)To ...

  6. HDU 4686 Arc of Dream (2013多校9 1001 题,矩阵)

    Arc of Dream Time Limit: 2000/2000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)Tota ...

  7. HDU 4685 Prince and Princess (2013多校8 1010题 二分匹配+强连通)

    Prince and Princess Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Othe ...

  8. HDU 4675 GCD of Sequence (2013多校7 1010题 数学题)

    GCD of Sequence Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)T ...

  9. HDU 4612 Warm up(2013多校2 1002 双连通分量)

    Warm up Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)Total Su ...

随机推荐

  1. C语言restrict限定符

    restrict是c99标准引入的,它只可以用于限定和约束指针,并表明指针是访问一个数据对象的唯一且初始的方式.即它告诉编译器,所有修改该指针所指向内存中内容的操作都必须通过该指针来修改,而不能通过其 ...

  2. C基础 内存越界和内存监测的简单处理

    引言 突然感觉要出去走走了, 醒了后 刷完牙就在联系coding, 不知不觉到了 黄昏. 看看天, 打开灯. 又感觉到了 夜夜夜夜 . 13年到北京务工, 遇到一批批NB的同龄人物. 一块工作, 一块 ...

  3. Context-Aware Network Embedding for Relation Modeling

    Context-Aware Network Embedding for Relation Modeling 论文:http://www.aclweb.org/anthology/P17-1158 创新 ...

  4. ZOJ-3318

    Strange Country Time Limit: 1 Second      Memory Limit: 32768 KB There are n cities in the dream cou ...

  5. gridcontrol的列头右键菜单问题

    Dev控件GridControl设置了一个右键菜单 this.gridControl1.ContextMenu = contextMenu2; 而GridControl在运行排序的时候,即 gridv ...

  6. Scikit Learn: 在python中机器学习

    转自:http://my.oschina.net/u/175377/blog/84420#OSC_h2_23 Scikit Learn: 在python中机器学习 Warning 警告:有些没能理解的 ...

  7. String的hashCode分析

    /** * Returns a hash code for this string. The hash code for a * {@code String} object is computed a ...

  8. react native 手势响应

    参考地址:https://www.jianshu.com/p/935e5c6a5064 官方文档地址:https://facebook.github.io/react-native/docs/panr ...

  9. ESLint 使用入门

    在团队协作中,为避免低级 Bug.产出风格统一的代码,会预先制定编码规范.使用 Lint 工具和代码风格检测工具,则可以辅助编码规范执行,有效控制代码质量. 在以前的项目中,我们选择 JSHint 和 ...

  10. 设置iframe 载入页面的效果跟直接打开这个页面一样

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xht ...