hdu 4633 Who's Aunt Zhang polya计数法

来源:互联网 发布:数据集成架构 编辑:程序博客网 时间:2024/05/02 01:33
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)



之前学过burnside引理和polya计数法,这题太明显是polya计数法的应用了,比赛的时候刚开始我只考虑了十种置换,后来想出应该是有24种的。。。不过由于要搞其他题,在这题上已经花了一定时间了,还是没继续搞了。赛后终于把所有情况给弄出来了,把k代入再利用扩展欧几里得求个逆元可以了。。。下次要果断!

#include <stdio.h>#define LL __int64const int mod = 10007;LL p[111];LL exgcd(LL a, LL b, LL &x, LL &y) {if(b==0) {x = 1;y = 0;return a;}LL ans = exgcd(b, a%b, y, x);y = y - a/b*x;return ans;}int main() {int i,k;int t, cas = 1;scanf("%d", &t);while(t--) {scanf("%d", &k);printf("Case %d: ", cas++);p[1] = k;for(i =2;i <= 100; i++)p[i] = p[i-1]*k%mod;LL ans = p[74]+(p[20]+p[20]+p[38])*3 + 8*p[26] + 6*p[38];LL x, y;LL d = exgcd(24, mod, x, y);x = (x%mod+mod)%mod;printf("%I64d\n", ans*x%mod);}return 0;}



原创粉丝点击