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 ;
}

最新文章

  1. sublime快捷键操作
  2. php类的__get和__set方法
  3. POJ 1195
  4. mac root用户初始密码设置
  5. PHP 下载远程图片
  6. 移动端touch实现下拉刷新
  7. s5pv210 的启动
  8. oracle的for和i++
  9. Java PDF页面设置——页面大小、页边距、纸张方向、页面旋转
  10. Error occurred in deployment step &#39;Retract Solution&#39;: xxx 无法反序列化,因为它没有公共的默认构造函数
  11. python中的魔法参数:*args和**kwargs
  12. rest-framework 序列化格式Restful API设计规范
  13. openresty 集成 keycloak-oauth-oidc
  14. spring 框架整合mybatis的源码分析
  15. 记录.NET Core部署到Linux之.NET Core环境搭建(1)
  16. 快速上手IOT视觉化开发工具Node-RED
  17. postgresql MVCC详解
  18. hiho一下 第二周 trie树
  19. ajax跨域的解决办法
  20. 【转】: 探索Lua5.2内部实现:虚拟机指令(3) Upvalues &amp; Globals

热门文章

  1. Linux内核中链表的实现与应用【转】
  2. nodejs 使用redis 管理session
  3. 【HDU3037】Saving Beans
  4. 如何在本地用vs调试微信接口
  5. [New learn] 网络基础-网络操作
  6. IntelliJ IDEA SpringBoot 使用第三方Tomcat以及部署
  7. LeetCode解题报告—— Reverse Nodes in k-Group &amp;&amp; Sudoku Solver
  8. Thinkphp模板中函数的使用
  9. Storm基本概念以及Topology的并发度
  10. SSM整合所需jar包