Summary of Polay theorem

Source: Internet
Author: User

Resources:

Url=yvescnlx_dlxo4ogje8w3_ 2qrobrxvxmbix81ppcxbgqbswxffwdn9frzy5xxakf7ggemy8k93jtpehkbzy66xoan0gidhbwcdndj7zurjm ">polay theorem

Feel the recent has been easy to meet such a topic .... A little more complicated, it's not going to be.

First a summed up theorem:

Use one of the simplest examples to illustrate

How many different images can I get from the 2*2 square, which is colored in black and white? The two schemes, which are matched by rotation, are considered the same.

Set G={P1,P2,..., PG} is a permutation group on Ω, such as permutation group g={to 0°. Turn 90°, turn 180°, turn 270°}

C (PK) is the number of cycles that displace the PK

The loop section of G1 permutation {to 0°} is 4. {(1), (2), (3), (4)}

G2 permutation {to 90°}, the Loop section is 1, {(4,3,2,1)}

G3 permutation {to 180°}, the Loop section is 2, {(1,3), (2,4)}

The loop section of G4 permutation {270°} is 1. {(1,2,3,4)}

The elements in Ω are colored with the colors in M,
Number of shading schemes is L = 1/| G|*[c1 (p1) +c1 (p2) +c1 (p3) +...c1 (P[g])

= 1/| G|*[m^c (p1) +m^c (p2) +m^c (p3) +...m^c (P[g])

| G| is the total number of permutations, the number of M colors

C1 (PI) refers to the number of fixed points of the displacement pi (both 1 points of the cyclic section)

watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvdtaxmdq2odu1mw==/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/southeast ">

Obvious four numbers are 16 2 4 2, respectively.

L = 1/| G| * [16 + 2 + 4 + 2] = 6

C (PI) refers to the number of cycles of the permutation pi.

L = 1/| G| *[2^4 + 2^1 + 2^2 + 2^1] = 6


Let's start with a simple topic:

POJ 2409:http://poj.org/problem?

id=2409

Main topic:

A necklace company produces bracelets. n beads form a ring, with the M color to the n beads dyed, you get a variety of bracelets. However, the same scheme is calculated by rotating and flipping the match.

For example, when 5 beads are dyed with 2 colors, the number of solutions is 8.

Solution of the problem:


One: rotate (for example, there are n beads.) The angle that can be rotated every time is 360/n)

Two: Flip (consider the axis of symmetry. Odd number of beads, that each axis of symmetry can pass through a bead. With a total of n axis of symmetry)

An even number of beads, each axis of symmetry through two beads, a common n/2 axis of symmetry, or every axis of symmetry does not pass through the beads, this symmetry axis is also a N/2

So all in all, either odd or even. The way of change is that there are 2*n kinds of flipping.


It can be proved that each flip of its cycle section is GCD (i,n) 0<i<=n

#include <iostream> #include <stdio.h> #include <string.h> #include <math.h>using namespace std ; int gcd (int a,int b) {    return b==0?a:gcd (b,a%b);} Long long rotate (int c,int n) {  //rotation  rotation (360/n) * I-degree    long long sum=0;    for (int i=1;i<=n;i++)        Sum+=pow (C*1.0,GCD (n,i));   The circular section of each rotation is gcd (n,i)    return sum; Long long Turn (int c,int n) {    //flip    long long sum=0;    if (n%2)        Sum+=n*pow (c*1.0, (n+2)/2);//odd the axis of symmetry is crossed by a bead a total  of n each permutation of the cyclic section is n/2+1    else    sum+=n/2* (POW ( C*1.0,N/2) +pow (c*1.0, (n+2)/2));  The even number is N/2 through the beads or not through the beads, and the n/2+1 and N/2 are   able to calculate the return sum with the following formula    ;} void Polya (int c,int n) {    int i,j;    Long long sum=0;    Sum+=rotate (c,n);    Sum+=turn (c,n);    printf ("%lld\n", sum/(2*n));} int main () {    int n,m;    while (scanf ("%d%d", &n,&m), n| | m) {        Polya (n,m);    }    return 0;}


< Span style= "font-size:18px" >

#include <cstring> #include <string> #include <fstream> #include <iostream> #include < iomanip> #include <cstdio> #include <cctype> #include <algorithm> #include <queue> #include <map> #include <set> #include <vector> #include <stack> #include <ctime> #include < cstdlib> #include <functional> #include <cmath>using namespace std #define PI acos ( -1.0) #define EPS 1e-7# Define INF 0x7fffffff#define llinf 0x7fffffffffffffff#define seed 1313131#define MOD 1000000007#define ll Long Long#defin E ull unsigned ll#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1//to replace the circulation section, Polya principle//perm[0..n-1] is 0. N-1 a permutation (permutation)//return displacement minimum period, NUM returns the number of circular nodes # define MAXN 1000int gcd (int a,int b) {return B?GCD (b,a%b): A;} int Polya (int* perm,int n,int& num) {int i,j,p,v[maxn]={0},ret=1;for (num=i=0;i<n;i++) if (!v[i]) {for (num++,j=0, p=i;! v[p=perm[p]];j++) V[P]=1;RET*=J/GCD (ret,j);} return ret;}    int main () {int perm1[6]={0,5,4,3,2,1}; int perm2[6]={1,0,5,4,3,2};    int num;    Cout<<polya (Perm2,6,num) <<endl; Cout<<num<<endl;}







Copyright notice: This article blog original article. Blogs, without consent, may not be reproduced.

Summary of Polay theorem

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.