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. 网络设备之net_device结构与操作

    net_device结构是一个很大的结构,其中包含了硬件信息,接口信息,其他辅助信息,以及设备操作函数等: 目前仍在读代码中,后续字段注释会逐渐补充: /** * struct net_device ...

  2. python实战===itchat

    import itchat itchat.login() friends=itchat.get_friends(update=True)[0:] male=female=other=0 for i i ...

  3. monkey测试===通过monkey测试检查app内存泄漏和cpu占用

    最近一直在研究monkey测试.网上资料很多,但都是一个抄一个的.原创的很少 我把检查app内存泄漏的情况梳理一下: 参考资料: Monkey测试策略:https://testerhome.com/t ...

  4. An unhandled exception of type 'System.TypeInitializationException' occurred in System.ServiceModel.dll

    异常“ An unhandled exception of type 'System.TypeInitializationException' occurred in System.ServiceMo ...

  5. expect 实现iterm2自动加载pem登录跳板机

    #!/usr/bin/expect set timeout spawn expect { "connecting (yes/no)?" { send "yes\r&quo ...

  6. IoT之车联网

    一. 背景 这是一个笔者在实习公司策划的关于车联网的小项目,也是笔者参加某竞赛的作品<基于云平台的车内滞留儿童状况监测与处理>,本项目旨在为因各种原因导致儿童滞留车内热死.闷死的社会性事件 ...

  7. vue-router 基础

    安装 NPM npm install vue-router 如果在一个模块化工程中使用它,必须要通过 Vue.use() 明确地安装路由功能: import Vue from 'vue' import ...

  8. ArcGIS Server配置端口

    写在前面,GIS服务器必须连通到外网,基于某些情况,可能一个机组有多态服务器,担任不同的角色,有Web服务器.数据库服务器和GIS服务器等,但是可能购买时只有一个外网IP,这样是不行的.JS脚本运行在 ...

  9. C语言 反序打印字符串中的单词

    int main() { char *str = "see you later"; int r = strlen(str); char * p = str; ; while(*st ...

  10. LeetCode解题报告—— Trapping Rain Water

    Given n non-negative integers representing an elevation map where the width of each bar is 1, comput ...