现在的位置: 首页 > 综合 > 正文

hdu 4633 Who’s Aunt Zhang(Burnside引理+乘法逆元)

2013年02月04日 ⁄ 综合 ⁄ 共 1016字 ⁄ 字号 评论关闭

根据Burnside引理,等价类数目等于所有 f 的不动点数目 C ( f ) 的平均值。

本题模型共有4大类置换,共24种:

1. 不做任何旋转 K ^ (54 + 12 + 8)

2. 绕相对面中心的轴转

1) 90度 K ^ (15 + 3 + 2) * 3

1) 180度 K ^ (28 + 6 + 4) * 3

1) 270度 K ^ (15 + 3 + 2) * 3

3. 绕相对棱中心的轴转

1) 180度 K ^ (27 + 7 + 4) * 6

4. 绕相对顶点的轴转

1) 120度 K ^ (18 + 4 + 4) * 4

1) 240度 K ^ (18 + 4 + 4) * 4

但数据比较大,要求逆元求解!

#include <cstdio>
#include <cstring>
#include <cctype>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <deque>
#include <algorithm>
using namespace std;
typedef long long ll;
const int mod = 10007;
int T,cas=1,n,ans;

int pow_mod(int x, int y)
{
    int ret = 1;
    while (y)
    {
        if (y&1) ret=(ret*x)%mod;
        x=(x*x)%mod;
        y>>=1;
    }
    return ret;
}

int x,y,d;

void exgcd(int a,int b)
{

    if(b==0)
    {
       x=1;
       y=0;
       d=a;
    }
    else
    {
        exgcd(b,a%b);
        int t=x;
        x=y;
        y=t-a/b*x;
    }
}
int main()
{
    scanf("%d",&T);
    while (T--)
    {
        scanf("%d",&n);
        ans=(pow_mod(n,74)+pow_mod(n,20)*6+pow_mod(n,38)*9+pow_mod(n,26)*8)%mod;
        exgcd(24,mod);
        ans=ans*((x+mod)%mod)%mod;  //欧几里得求逆元
       // ans=(ans*pow_mod(24,mod-2))%mod;  //费马定理求逆元,速度快点
        printf("Case %d: %d\n",cas++,ans);
    }
    return 0;
}

抱歉!评论已关闭.