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. 005 JAVA多线程和并发基础面试问答(转载)

    原文链接:http://ifeve.com/java-multi-threading-concurrency-interview-questions-with-answers/ 多线程和并发问题是Ja ...

  2. aspxgridview export导出数据,把true显示成‘是’

    项目原因,数据库中的数据是‘true’还有‘false’,但是在页面上要显示为‘是否’,导出来的时候也是要显示成‘是否’ 要在web页面当中显示成‘是否’,只要在gridview的CustomColu ...

  3. 理解rest架构

    越来越多的人开始意识到,网站即软件,而且是一种新型的软件. 这种"互联网软件"采用客户端/服务器模式,建立在分布式体系上,通过互联网通信,具有高延时(high latency).高 ...

  4. 【python】msgpack使用

    1.存储数据 import msgpack var={'a':'this','b':'is','c':'a test'} with open('file.name','wb') as f: msgpa ...

  5. Django 如何实现文件下载

    1. 思路: 文件,让用户下载 - a标签+静态文件 - 设置响应头(django如何实现文件下载) 2. a标签实现 <a href="/static/xxx.xlsx"& ...

  6. IEDA自动清除无用的import

    Before After Step     快捷键展示格式化对话框:ctrl + shift + alt + l   格式化快捷键:ctrl + alt + l <wiz_tmp_tag id= ...

  7. Linux下安装PHP环境(非集成)

    一.安装Apache1.到官网下载  http://httpd.apache.org/download.cgi    2.安装apache [root@localhost 52lamp]# mkdir ...

  8. 【剑指offer】面试题 29. 顺时针打印矩阵

    面试题 29. 顺时针打印矩阵 题目描述 题目:输入一个矩阵,按照从外向里以顺时针的顺序依次打印出每一个数字,例如,如果输入如下矩阵: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 ...

  9. firfox与about:config

    ¤什么是about:config¤about:config是Firefox的设置页面,Firefox提供了不少高级设置选项在这里以便让你可以更加详细地控制Firefox的运行方式.官方不推荐用户手工修 ...

  10. AngularJS自定义指令及指令配置项

    两种写法 //第一种 angular.module('MyApp',[]) .directive('zl1',zl1) .controller('con1',['$scope',func1]); fu ...