UVA 10294 necklaces and bracelets (Replacement)

Burnside Lemma: For a permutation \ (f \) , if a coloring scheme \ (s \) after replacement of the same, saying that \ (s \) is \ (f \) fixed point. The \ (F \) number of fixed point referred to as \ (C (f) \) , then the equivalence class number can be shown as \ (C (f) \) average.

For permutation is a permutation of a group of \ (F \) , \ (C (F) \) is colored all embodiments, those after replacement \ (F \) Number coloring scheme can be interchangeable (i.e., equivalent) of

Because substitutions may be split into a plurality of cycles, each element in the permutation can be regarded as a node, each node must have a degree and the penetration, it will certainly form a plurality of rings, in substitution \ (F \) Fixed point, is decomposed into each ring, the color must be the same (because they can reach each other by substitution). Assuming that the number of cycles a permutation section for \ (m (F) \) , then the \ (C (f) = k ^ {m (f)} \) where k is the number of coloring.

UVA 10294 necklaces and bracelets

Portal

Liu Rujia white paper 146

polya count naked title

There are two replacement that rotate and flip, only the first replacement necklaces, bracelets have both. Beads disposed numbered 0 ~ n-1.

Rotation:

A total of n-1 kinds of rotational displacement mode, i.e., the i-th pitch beads rotation i, then can be calculated starting from the number 0 beads, to rotate \ (lcm (i, n) / i \) times to go to the first position, then the cycle length of \ (\ {n-FRAC} {GCD (I, n-)} \) . The total displacement total \ (gcd (i, n) \) cycles, the rotation of such substitutions, consensus \ (a = \ sum_ {i = 0} ^ {n-1} t ^ {gcd (i, n) } \) a fixed point

Overturn

When n is odd (n-gon may want vertices), there are n symmetry axis, each axis forming a symmetry \ ((n-1) / 2 \) of length 2, and a length of 1 cycle, i.e., (n + 1) / 2 cycles. The total number of such substitutions Fixed point \ (^ B = {NT \ FRAC +. 1 {n-2}}} {\) .

When n is even, there are two axis of symmetry. Beads are passing through the axis of symmetry \ (\ frac {n} { 2} \) strips, each formed \ (n / 2-1 \) having a length of two cycles and a cycle length of 1, 2; not wear axis of symmetry through the beads are \ (\ FRAC {n-2}} {\) , each forming a \ (n / 2 \) of length 2 cycles. The total number of substitutions such as fixed point \ (b = \ frac {n } {2} (t ^ {n / 2 + 1} + t ^ {n / 2}) \)

const int N = 50 + 5;

int n, t;
ll power[N];
ll gcd(int a,int b){
    return b == 0 ? a : gcd(b, a % b);
}
int main() {
    while(scanf("%d%d",&n,&t) == 2 && n){
        power[0] = 1;
        for (int i = 1; i <= n;i++)
            power[i] = power[i - 1] * t;
        ll a = 0;
        for (int i = 0; i < n;i++)
            a += power[gcd(i, n)];
        ll b = 0;
        if(n % 2 == 1){
            b = n * power[(n + 1) / 2];
        }else
            b = n / 2 * (power[n / 2 + 1] + power[n / 2]);
        cout << a / n << ' ' << (a + b) / 2 / n << endl;
    }
    return 0;
}

Guess you like

Origin www.cnblogs.com/1625--H/p/12333003.html