Polya Theorem entry [Burnside Lemma, Polya theorem, Euler function]

This blog focuses on application of $ Polya, more detailed proof, please Baidu. $
___

$ Burnside Lemma $

$$L=\frac{1}{|G|}\sum_{i=1}^{|G|}D(a_i)$$

$ L $: number of essentially different solutions.
$ G $: replacement cluster set.
$ $ A_i: permutation group of substitutions $ I $.
$ D (a_i) $: $ a_i $ permutation performed, the state does not the number of program changes.

The lemma below not so much with the content, you can ignore.
___
$ Problem $ link
has $ N $ a stone circle, using $ M $ dyed colors, how many different schemes beg for nature.

Take issues into $ Polya Theorem $ $ ↓ $


$ Polya Theorem $

$$L=\frac{1}{|G|}\sum_{i=1}^{|G|}M^{C(g_i)}$$

First threw formula.

This question is of the permutation group $ G $: $ 0 $ secondary transfer, secondary transfer $ 1 $ ... $ N-1 $ transfected times (both clockwise rotation).
When the rotational satisfy $ k $ positions, and the original state same, then the $ I $ color of the position equal to $ (i + k)% N $ color of the position,
rotation $ t $ times, still feel the same position, i.e., $ I $ position $ (I + T K)% N $ position the same color,
the rotational $ I $ $ t $ a $ k $ times, will be able to return to the original position, i.e., unlimited rotation,
so that on all $ I $ $ (T I +
K)% N $ presenting a closed position the $ \ color {red} {} $ section cycle.
after the set time $ t $ turn, the first back $ I $ position,
t * k = lcm (k, N) $ = \ frac {k * GCD {} N (K, N)} $,
$ \ THEREFORE T = \ FRAC GCD {{N} (K, N)} $,

$ T $ to $ \ color {red} {} $ loop section length, $ \ color {red} {} circular section in an amount of $ $ \ frac {N} {t} = gcd (k, N) $.

The number of colors to the formula $ M $; at $ $ G_i replaced with a $ C (g_i) $ a $ \ color {red} {} $ circular section.

In this question $ C (g_i) = gcd ( k, N) $, $$ \ therefore Ans = L = \ frac {1} {N} \ sum_ {k = 0} ^ {N-1} M ^ {gcd (K, N)} $$
___

$ Expand $ 1

If the problem increases $ \ color {red} {} $ isomorphic symmetry, it means that the original two different schemes symmetric timepiece as a program,
by $ N $ parity classification discussion:

  1. $ $ N is odd, there is a point of the axis of symmetry, number of cycles of knots $ \ frac {N + 1} {2} $, $ N $ total permutation symmetry axis, the answers contribution $ \ frac { N M ^ {\ FRAC +. 1 {N} {2}}}} $ {2N
    final answer is $$ Ans = L = \ frac { 1} {2N} (\ sum_ {k = 0} ^ {N- } ^ {M GCD. 1 (K, N)} N +
    M ^ {\ FRAC. 1} + {N} {2}) $$
  2. $ $ N is an even number, there may be no point symmetry axis, there are two points may both have an axis of symmetry $ \ frac {N} {2 } $ types, a total of $ N $ substitutions symmetry axis,
    the axis of symmetry when no point on, the number of loop section is $ \ frac {N} {2 } $, answers contribution $ \ frac {M ^ {\ frac {N} {2}}} {2N} $, contribute to the total $ \ FRAC {\ FRAC {N} {2} M {^ \ FRAC {{N} {2}}}} $ 2N.
    when the bit axis of symmetry, number of cycles of knots $ \ frac {N} {2 } 1 + $, answers contribution $ \ frac {M ^ {\ frac {N} {2} +1}} {2N} $, the total contribution of $ \ FRAC {\ FRAC {N} {2}
    M {^ \ frac {N} {2} +1}} {2N} $.

    所以最后的答案为
    $$Ans=L=\frac{1}{2N}(\sum_{k=0}^{N-1}M^{gcd(k,N)}+\frac{N}{2}M^{\frac{N}{2}}+\frac{N}{2}M^{\frac{N}{2}+1})$$
    ___

$拓展2$

若 $\color{red}{N<=10^9}$ , $O(N)$计算下式会 $TLE$, 需要更快的办法,
$$Ans=L=\frac{1}{N}\sum_{k=0}^{N-1}M^{gcd(k,N)}$$

由于 $gcd(k,N)|N$, 而$N$的约数不会超过 $2\sqrt{N}$ 个,
考虑枚举 $d$, $(d|N)$
则就只需统计 $gcd(k,N)=d$ 的 $k$ 的个数.
$d=gcd(k,N)=gcd(dt, d\frac{N}{d})$
则 $t$ 与 $\frac{N}{d}$ 互质, 即 $\color{red}{gcd(t, \frac{N}{d}) = 1}$.
$\therefore \color{red}{\varphi(\frac{N}{d})}$ 即为 $gcd(k,N)=d$ 的 $k$ 的个数.

于是 $$Ans=L=\frac{1}{N}\sum_{d|N}\varphi(\frac{N}{d}) *M^d$$
.

$如何求解 \varphi(x)?$
根据定义: $$\varphi(x)=x\prod_{p_i|x}(1-\frac{1}{p_i})$$
通分得: $\varphi(x) = x\prod_{p_i|x}\frac{p_i-1}{p_i}$
按上式实现, 时间复杂度小于 $O(\sqrt{N})$, 均摊 $O(logN)?$
这里给出求解函数,

int Get_phi(int x){
    int s = x;
    for(int i = 2; i*i <= x; i ++)
        if(x % i == 0){ //找到一个质因数
            s = s/i*(i-1);
            while(x%i == 0) x /= i;
        }
    if(x > 1) s = s/x*(x-1);    //不可能出现两个大于 sqrt(N) 的质因数, 所以只可能剩下一个, 处理掉就好 .
    return s;
}

所以 $O(\sqrt{N}),O(logN)$ 分别求出所有约数 $d$ 和 $\varphi(\frac{N}{d})$ 即可, 时间复杂度 $O(\sqrt{N}logN)$.
___
$\mathcal{Code}$

#include<bits/stdc++.h>
#define reg register

const int mod = 1e9 + 7;

int T;
int N;

int phi(int x){
        int s = x;
        for(reg int i = 2; i*i <= x; i ++)
                if(x % i == 0){
                        s = s/i * (i-1);
                        while(x % i == 0) x /= i;
                }
        if(x > 1) s = s/x * (x-1);
        return s;
}

int KSM(int a, int b){
        int s = 1; a %= mod;
        while(b){
                if(b & 1) s = 1ll*s*a % mod;
                a = 1ll*a*a % mod, b >>= 1;
        }
        return s;
}

void Work(){
        scanf("%d", &N);
        int Ans = 0;
        int lim = sqrt(N);
        for(reg int d = 1; d <= lim; d ++){
                if(N % d) continue ;
                Ans = ( 1ll*Ans + (1ll*phi(N/d) * KSM(N, d) % mod) ) % mod;
                int d_2 = N / d;
                if(d_2 == d) continue ;
                Ans = ( 1ll*Ans + (1ll*phi(N/d_2) * KSM(N, d_2) % mod) ) % mod;
        }
        printf("%d\n", (1ll*Ans*KSM(N, mod-2)) % mod);
}

int main(){
        scanf("%d", &T);
        while(T --) Work();
        return 0;
}

$例题$

更多例题请戳 这里 .


Guess you like

Origin www.cnblogs.com/zbr162/p/11404147.html