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. MongoDB的安装配置、基本操作及Perl操作MongoDB

    MongoDB的安装配置.基本操作及Perl操作MongoDB http://www.myhack58.com/Article/60/63/2014/42353.htm

  2. 2017中国大学生程序设计竞赛 - 网络选拔赛 HDU 6152 Friend-Graph 暴暴暴暴力

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6152 题意:判定一个无向图是否有三个点的团或者三个点的独立集. 解法:Ramsey theorem,n ...

  3. caffe solver.prototxt 生成

    from caffe.proto import caffe_pb2 s = caffe_pb2.SolverParameter() path='/home/xxx/data/' solver_file ...

  4. node.js2

    同步是指:同步阻塞操作,异步是指:异步非阻塞操作. 第一部分:fs模块 1.引入fs模块 require('fs'); 2.写文件 01.异步写:writeFile fs.writeFile(path ...

  5. 安装lszrz,用于上传文件

    wget http://down1.chinaunix.net/distfiles/lrzsz-0.12.20.tar.gztar zxvf lrzsz-0.12.20.tar.gzcd lrzsz- ...

  6. leetcode 141 142. Linked List Cycle

    题目描述: 不用辅助空间判断,链表中是否有环 /** * Definition for singly-linked list. * struct ListNode { * int val; * Lis ...

  7. 海量文件查重SimHash和Minhash

    SimHash 事实上,传统比较两个文本相似性的方法,大多是将文本分词之后,转化为特征向量距离的度量,比如常见的欧氏距离.海明距离或者余弦角度等等.两两比较固然能很好地适应,但这种方法的一个最大的缺点 ...

  8. 深度学习方法:受限玻尔兹曼机RBM(一)基本概念

    欢迎转载,转载请注明:本文出自Bin的专栏blog.csdn.net/xbinworld. 技术交流QQ群:433250724,欢迎对算法.技术.应用感兴趣的同学加入. 最近在复习经典机器学习算法的同 ...

  9. 关于在ASP.NET MVC 中使用EF的Code First的方式来读取数据库时的Validation failed for one or more entities. See 'EntityValidationErrors' property for more details.

    今天在做一个小网站的时候遇到很多问题唉,我还是个菜鸟,懂的也不多,今天一个表单的提交按钮用不了,都弄了几个小时唉.不过最后还是搞定了,还有浏览器有开发人员选项,不然我都不知道我还要继续排查多久哦,今天 ...

  10. .net core 2.0学习记录(三):内置IOC与DI的使用

    本篇的话介绍下IOC和ID的含义以及如何使用.Net Core中的DI. 一.我是这么理解IOC和DI的: IOC:没有用IOC之前是直接new实例来赋值,使用IOC之后是通过在运行的时候根据配置来实 ...