Mathematics noip thematic review of (6) - Replacement and Its Applications

1. Basic concepts:

In simple terms, it is the replacement of the n elements to make a full permutation. , Such as 1,2,3,4 become 3,1,2,4, 4,3,2,1 or separately into Generally, a variable a1,2 becomes a2, ... is referred to as a permutation:
\ [\ left (\ begin {
matrix} 1 & 2 \ cdots & n \\ a_1 & a_2 \ cdots & a_n \\ \ end {matrix} \ right) \] substitution is actually one mapping,

(1) can be an array of f = {a1, a2, ..., an} is represented a substitution of 1 ~ n, where f [i] represents element i is mapped to (f [0] is not used) .

(2) f can be seen as the domain and range are {1,2,3, ..., n} function wherein f (1) = a1, f (2) = a2, f (3) = a3, ..., f (n) = an. Due to the different elements are mapped to a different number, this function is reversible.

Multiplication may be defined between the replacement, corresponding to the composite function.

Such substitution f = {1,3,2} and g = {2,1,3}, a product of fg = {2,3,1}, because of changes in each element is 1-> 1-> 2,2-> 3-> 3,3> 2-> 1.

On complex mathematical function is associative, it is also replaced multiplication is associative. Note: Replacement multiplication is not commutative.

For ease of handling, often the replacement decomposed into a product cycle, such as:
\ [\ left (\ the begin {Matrix}. 1 & 2 &. 3 &. 4 &. 5 \\. 3 &. 5 &. 1 &. 4 & 2 \\ \ End {Matrix} \ right) = (. 1 \ quad3) (2 \ quad5 ) (4) \]
Why any such replacement can decompose it? As each element is a node, if a B becomes, even a directed edge a-> b, then each element has exactly one predecessor and successor node node (since it must only a number is mapped , and only a certain number mapped to it, otherwise the number of the replaced every number is no longer in the 1 ~ n, the number will be deleted), so that only a plurality of FIG directed cycle, wherein each of corresponding to a ring cycle.

Although in general, the multiplication is not commutative substitutions, but it does not intersect the cycle, in any order are multiplied equivalent.

We call decomposition cycle loop section number in circulation for the replacement. For example (13) (25) (4) of section 3 of the cycle.

2. Counting Problems equivalence class

Classic question: painted in black and white squares 2 * 2, there are several ways?

The answer: 16 species.

But if define a rotational operation, a predetermined rotated counterclockwise by 90 degrees, 180 degrees or 270 degrees embodiment regarded as a kind of the same, then the answer becomes a six.

Such a problem is called the equivalence class count problems.

The title will define a equivalence relation, equivalence relation satisfying elements are considered in the same class, the statistics only once .

Equivalence relations need to meet reflexive (each element and its own equivalent), symmetry (if A and B are equivalent, the equivalent A and B) and transitive (if A and B are equivalent, B and C equivalent, the equivalent A and C).

To count the number of equivalence classes, first we need to describe a set F substitution equivalence relation. If a substitution wherein a mapping scheme to another embodiment, said both are equivalent. Note: the product of any two F replacement should be in F, F can not otherwise constitute a permutation group. Such as: F = {0 degrees counter-clockwise rotation, counterclockwise rotation of 90 degrees, 270 degrees rotated counterclockwise} definition is not legal, since the two 90-degree counterclockwise rotation, that is rotated 180 degrees counterclockwise, and F, but it did not define the rotated counterclockwise by 180 degrees.

Burnside theorem: f for a replacement, if a shader program s after the replacement constant, s is called fixed point of f. The number of fixed point f is denoted as C (f), it can be shown that for all the equivalence class number C (f) the average value.

How to find Fixed Point C (f) the number of it? Generally, if the replacement is decomposed into the product of f m (f) cycles, then all colors within each cycle of the grid must be the same, assuming k colors painted, there are C (f) = k ^ (m (f)) . Into Burnside lemma of Polya Theorem obtained after expression.

Polya theorem: the number of all equivalent classes is equal to the average number of substitution of f k ^ (m (f)) of.

Example: necklaces and bracelets (Arif in Dhaka (First Love Part 2))

The meaning of problems: n stones with necklaces and bracelets, each gem colors can be one kind of color of t, when A is rotated through necklaces necklaces have B, A and B belong to a class of necklaces, bracelets and not rotation may also be reversed when the flip obtained through a class B class bracelet bracelet a and B belong to a class bracelets, jewels asking n, t colors, how many can be strung together necklaces and bracelets?

Analysis: Rotation: If i counterclockwise rotation of the pitch beads, the beads 0, i, 2i, ... constitute one cycle. Provided the total cycle k elements, the (i k) = 0 n-% (return to the original 0), the i values of both sides of the equation k = n * y, should be lcm (n, i), it i * k = lcm (n, i) =

n * i / gcd (n, i), can be obtained so that k = n / gcd (n, i). By symmetry, 1,2i + 1, ... constitute cycles, each cycle of the same length, a total number of n, the length of one cycle of n / gcd (n, i) , so that the number of cycle was gcd (n, i). The fixed point number of substitutions is:
\ [A = \ sum_ {I} = 0 {n ^ T ^ {}. 1-GCD (I, n)} \]
Flip: When n is odd, the axis of symmetry there are n (respectively through each of the bead to make an axis of symmetry), each forming a symmetry axis (n-1) / 2 cycles of length 2 (two point-symmetric about the symmetry axis of a loop configuration, minus at that point symmetry axis) and a length of one cycle, i.e., (n + 1) / 2 cycles. The total number of substitutions of these fixed points is
\ [b = nt ^ {\
frac {n + 1} {2}} \] When n is even, there are two axis of symmetry, passing through the beads are n / 2 Article , are each formed n / 2-1 cycles of length 2 and two lengths of the loop 1; a symmetry axis does not pass through the beads are n / 2 strips each forming the n / 2 cycles of length 2. The total number of fixed point is replaced with
\ [b = \ frac {n } {2} (t ^ {\ frac {n} {2} +1} + t ^ {\ frac {n} {2}}) \]
according Polya theorem, the total number of equivalence class necklace a / n, the total number of equivalence classes bracelet (a + b) / 2n.

#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
const int maxn=55;

int gcd(int a,int b)
{
    return b==0?a:gcd(b,a%b);
}

int main()
{
    int n,t;
    while(scanf("%d%d",&n,&t)==2&&n)
    {
        LL pow[maxn];
        pow[0]=1;
        for(int i=1;i<=n;++i) pow[i]=pow[i-1]*t;
        LL a=0;
        for(int i=0;i<n;++i) a+=pow[gcd(n,i)];
        LL b=0;
        if(n%2==1) b=n*pow[(n+1)/2];
        else b=n/2*(pow[n/2+1]+pow[n/2]);
        printf("%lld %lld\n",a/b,(a+b)/2/n);
    }
    return 0;
}

Guess you like

Origin www.cnblogs.com/iwillenter-top1/p/11622017.html