[HNOI2008] Cards

Description

给出 (n) 张牌,要求染出 (a) 种红色,(b) 种蓝色,(c)zyz之色绿色。同时给出 (m) 种洗牌方法,两种染色方案相同当且仅当可以通过洗牌从一种方案变成另一种方案。问有多少不同的染色方案。输入数据保证任意多次洗牌都可用这m种洗牌法中的一种代替,且对每种洗牌法,都存在一种洗牌法使得能回到原状态。

(nleq 60)

Solution

题目的保证非常吼啊,如果再加上“不动”这个置换就形成了一个群啊。

(burnside) 引理,我们只需要求出每种置换的不动点即可。

感性理解一下,除了“不动”这个置换,其它置换都没有不动点。

于是答案变成了多重集合的排列除以 (m+1)

Code

#include<bits/stdc++.h>
using std::min;
using std::max;
using std::swap;
using std::vector;
typedef double db;
typedef long long ll;
#define pb(A) push_back(A)
#define pii std::pair<int,int>
#define all(A) A.begin(),A.end()
#define mp(A,B) std::make_pair(A,B)

int a,b,c,n,m,mod;

int getint(){
    int X=0,w=0;char ch=getchar();
    while(!isdigit(ch))w|=ch=='-',ch=getchar();
    while( isdigit(ch))X=X*10+ch-48,ch=getchar();
    if(w) return -X;return X;
}

int fac(int x){
    int ans=1;
    for(int i=2;i<=x;i++) (ans*=i)%=mod;
    return ans;
}

int ksm(int a,int b,int ans=1){
    while(b){
        if(b&1) ans=ans*a%mod;
        a=a*a%mod;b>>=1;
    } return ans;
}

signed main(){
    a=getint(),b=getint(),c=getint(),m=getint(),mod=getint();
    printf("%d
",fac(a+b+c)*ksm(fac(a),mod-2)%mod*ksm(fac(b),mod-2)%mod*ksm(fac(c),mod-2)%mod*ksm(m+1,mod-2)%mod);
    return 0;
}

原文地址:https://www.cnblogs.com/YoungNeal/p/10300614.html