You are on page 1of 12

PólyaPrinciple and Application

East China Normal University High School Fu Wenjie


PólyaThe principle is combination of mathematics to
calculate all of a mutually combined state of the number of
different highly efficient, simple tool. Now, I will tell
you about what isPólyaPrinciple and its application. Please
see below this sample item:
Example [1]
Correct2 * 2The square painted with black and white
colors, and asked how many different images to get? After
rotation to make it consistent with the two programs, it is
regarded as the same kind of program
【problem analysis】
Due to the small size of the problem, we can put all
the coloring scheme listed.

A method of rotating a 2 * 2 matrix of a total of 4: 0


degree rotation, rotated by 90 degrees, rotated by 180
degrees and rotated 270 degrees. (Note: This is the default
rotation clockwise rotation) we have been tried and found
different from each other a total of only six kinds: C3,
C4, C5, C6 can be varied by mutual rotation is obtained,
the same count; C7, C8, C9, C10 is the same; C11, C12 is
the same; C13, C14, C15, C16 are the same; are each
independently a C1 and C2 are two. Thus, we get the
following six different schemes.

However, once

this issue by the phalanx phalanx becomes 2 * 2 20 * 20 *


200 or even 200, we can no longer dwell on the use of Pólya
principle has become a good problem-solving methods. Before
contacting Pólya principle, first briefly introduce some
concepts Pólya in principle to use.
group: Given a set G = {a, b, c, ...} and the set of binary operation on G,
and satisfies:
(A) closed:a, BG, cG, A * b = c.

(B) binding law:a, B, cG, (A * b) * c = a * (b * c).

(C) the identity element:eG, aG, A * e = e * a = a.

(D) the inverse element:aG, bG, A * b = b * a = e, denoted


b = a-1.
Set G is called a group under the operation *, G is the group referred to.
Generally abbreviated as a * b ab.

Replacement: N elements 1,2, ..., n denotes a

permutation between one of a number A1 is substituted in the 1 to n, a2 2


is substituted with a number of 1 to n, n is 1 up to n, a certain number of
an substituted, and a1, a2, ..., an are different. In this example there are
four substitutions:

Turn 0 a1

Turn 90

a2 =

Turn 180

a3 =
Turn 270

a4 =
Permutation group: Elements of permutation groups is replaced, the
replacement operation is connected. E.g:

You can verify permutation groups Groups meet four conditions.


This problem in turn permutation group G = {0, Turn

90,turn180,turn270}
We look at a formula:│Ek│ · │Zk│ = │G│ k = 1 ... n
The formula is a very important object of study is the number of elements
of the group, is very useful.
Zk (K fixed displacement class):Let G 1 ... n of the permutation group.
If K is an element in 1 ... n, G K remains constant manipulation of the
entire substitution, referred to Zk, manipulation is called G K remains
immobile substitution class, substitution classes referred K does not
move.

As in this

example:G is a coloring scheme permutation group of 1 to 16. For


Scheme 1, Scheme 1 that the four substitutions are kept unchanged, Z1 =
{a1, a2, a3, a4}; for the embodiment 3, it is only replaced with a1
unchanged, Z3 = {a1}; for Scheme 11 , a1 and a3 that the substitution
scheme which remains unchanged, Z11 = {a1, a3}.
EK (equivalence classes):Let G 1 ... n of the permutation group. If K is
1 ... n in an element, the trajectory K in the effect of the G, denoted Ek.
I.e. the set of K can be changed to G under the action of all elements.
As in this example:Scheme 1 In Scheme 1 are four displacement action,
thus E1 = {1}; Scheme 3, at a1 is 3, becomes the a2 6, at 5 becomes a3,
at 4 becomes a4, Therefore E3 = {3,4,5,6}; scheme 11, in the a1, a3 is at
11, at 12 becomes a2, a4, so E11 = {11,12}.
Data in the present embodiment, in full compliance with
this theorem.As in this example:
│E1│ · │Z1│ = 14 = 4 = │G│

│E3│ · │Z3│ = 41 = 4 = │G│

│E11│ · │Z11│ = 22 = 4 = │G│


Due to space limitations, there is no proof of this theorem.
He went on to study the sum of each element in each permutation of
the same number of times. As follows:
Replacement 1 2 ...... 16 D (ai)

\ Sij \ j

elements

aI

S1,1 S1,2 ...... S1,16 D (a1)


a1a2
S2,1 S2,2 ...... S2,16 D (a2)
a3
S3,1 S3,2 ...... S3,16 D (a3)
a4
S4,1 S4,2 ...... S4,16 D (a4)

│Zj│ │Z1│ │Z2│ ...... │Z16│

among them

D (aj) at a substitution represented by a constant number of elements


aj
As this question in:Coloring no change in Scheme 1 a1, S1,1 = 1; a3
fluctuates in Scheme 3, S3,3 = 0; no change at the 16 change permutation
schemes a1, D (a1) = 16; the substitution in these two programs only 1,2
a2 no fluctuation, D (a2) = 2.
Under normal circumstances, we can conclude that:
We examined the left ceremony.
May wish to set N = {1,......, N} L total of equivalence classes, N = E1
+ E2 + ...... + EL, then when j and k belong to the same equivalence
class, there│Zj│ = │Zk│. and so

L here is we askThe number of

combinations of mutually different states. So we come to:


Using this equation the solution of this problem, we can get L = (16 + 2 +
4 + 2) / 4 = 6 and the results obtained coincides preceding enumeration.
This equation is called the Burnside lemma.
However, we found that to calculate the value of D (aj) is not very
easy, if the search method, the size of the total time is O (nsp). (N
represents the number of elements, s is the number of replacement, p
represents the number of lattice, where n is the size of a large) The next
step is to find a simple D (aj) calculation method. First introduced the
concept of a cycle:
cycle: Remember

Referred to as n-order loop. Each substitution can write the product of


several disjoint cycle, two cycles (a1a2 ... an) and (b1b2 ... bn) refers ai
disjointbj, I, j = 1,2, ..., n. E.g:

This representation is unique. The number of cycles section showing the


number of the substitution is circulating. For example, (13) the number
(25) (4) of section 3 of the cycle.
With this foundation, you can do further research, we have a different
angle to consider this issue. We give each box label 2 * 2 square, as
shown below:
2 1
3 4
  Configured permutation group G '= {g1, g2, g3, g4}, | G' | = 4, so
the number of cycles section gi is c (gi) (i = 1,2,3,4)
Under the action of G ', wherein
g1 indicates a transposed 0 °, i.e., g1 = (1) (2) (3) (4) c (g1) = 4
g2 indicates a transposed 90 °, i.e., g2 = (4 3 2 1) c (g2) = 1
    g3 indicates a transposed 180 °, i.e., g3 = (1 3) (2 4) c (g3) = 2
    g4 indicates a transposed 270 °, i.e., g4 = (1 2 3 4)     c
(g4) = 1
  We can see that same cycle gi section of an object coated with the

same color of the resulting image data MC (gi) corresponds exactly to the

same number of picture ai displace under the action of G, i.e.,

   2c (g1) = 24 = 16 = D (a1) 2c (g2) = 21 = 2 = D (a2)

   2c (g3) = 22 = 4 = D (a3) 2c (g4) = 21 = 2 = D (a4)


This leads us to a conclusion:

  Let G be a permutation group of p

objects, with object p m painting colors, it is different for the staining


protocol:
Where G = {g1, ... gs} c (gi) is the number of cyclic permutation
section of gi (i = 1 ... s)
This is called Pólya theorem. We found that the use Pólya theorem
time complexity is O (sp) (where s is the number of substitutions, P
represents the number of lattices), with previously obtained of Burnside
contrast, there has been much improved, its advantages will be very
obvious. Pólya Theorem fully tap the internal relations of the study,
summed up the law, eliminating a lot of unnecessary blind search, the
time scale to solve these problems down to a very low level.
Now the question changed to: nn square, each of the small cells of
m colors may be coated, the total number of rotational operation in the
nature of solutions of different requirements.
【problem analysis】
The method of searching look at a very easy to think of. (See
Appendix)
The efficiency of this search is very low, it also has a lot of room for
improvement. Front, our approach is to search after the sentence, such
blindness is extremely high. We need to search the side edge sentenced
avoid excessive unnecessary to enumerate, we hope to determine the
boundary conditions are completely integrated into the search and going
to eliminate invalid enumeration. This wonderful hope can be achieved.

We separated the phalanx

do not overlap length [(n + 1) / 2], width of [n / 2] of the four matrices.


When n is an even number, points just finished; when n is odd, the center
leaving a grid, it is not moving at all rotation, so that the coating color
has no effect on any other grid. Let m be the colors is 0 ~ m-1, we
represent the color of each cell in the matrix are sequentially number
(upper left corner from left to right, top to bottom; the top right from top
to bottom, right to left ;......) Are arranged in m-ary numbers, then it can
be represented as a decimal number, which is in the range of 0 ~ m [n2 /
4] -1. (As [n / 2] * [(n + 1) / 2] = [n2 / 4]) Thus, we put a square
simplified four integers. We just find each equivalence class the largest
number in the upper left corner of the program (if the same upper-left
corner, then clockwise direction moving relatively) so that, at the time the
enumeration of the other three the number is not more than a certain
number of the top left corner efficiency should be the highest.
Further consideration, when the number of the upper left corner of i,
(0iR-1) so that R = m [n2 / 4]
It can be divided into the following four categories:
 Other three integer less than i, a total of i3.

 Upper right corner i, less than the other two integers i, a total of i2.

 The upper right corner, lower right corner i, is not greater than the
lower left corner of i, i + 1 th common.
 Lower right corner i, less than the other two integers i, and the
number is not less than the lower left corner to the upper right corner,
co i (i + 1) / 2 th.
therefore,

When n is odd, also by a m.


Thus we get a clever formula. However, we should expect to see this
formula requires high intelligence and pay a lot of time. On the other
hand, this method can only be useful for this question can not be widely
applied to a class of questions, with great uncertainty factors. So, if you
can grasp the principle of a wide range of applicable, it will be a great
help to the solution of this type of problem.
Here we adopt Pólya theorem. Three steps we can to solve this
problem.
1. Determining the permutation group
Here it is clear that only four substitutions: 0 rpm, Turn

90,turn180,turn270. Therefore, replacement of the group G =

{0 rpm, Turn 90,turn180,turn270}.


2. Counting the number of cycles section
First, for each grid sequentially numbered (1 ~ n2), and then
the open state after recording a two-dimensional array replacement.
Counting the number of the last section in each cycle substituted by
searching, efficiency of first power level.
3. Into the formula

Namely the use of Pólya theorem final

result.
[Program] problem solution
const
maxn = 10;
var
a, b: array [1..maxn, 1..maxn] of integer; {record} square state
i, j, m, n: integer; {m number of colors; n-matrix size}
l, l1: longint;
procedure xz; {90 the rotation matrix}
var
i, j: integer;
begin
for i: = 1 to n do
for j: = 1 to n do
a [j, n + 1-i]: = b [i, j];
b: = a
end;
procedure xhj; {number of cycles of the current state calculating section}
var
i, j, i1, j1, k, p: integer;
begin
k: = 0; {section used to record the number of cycles, cleared}
for i: = 1 to n do
for j: = 1 to n do
if a [i, j]> 0 then {not currently visited search grid}
begin
inc (k); {1} plus the number of loop section
i1: = (a [i, j] -1) div n;
j1: = (a [i, j] -1) mod n + 1; {get the next cycle lattice}
a [i, j]: = 0; {} indicates that the cell has been visited
while a [i1, j1]> 0 do begin
p: = a [i1, j1]; {} temporary grid current information
a [i1, j1]: = 0; {set} visited flag
i1: = (p-1) div n + 1;
j1: = (p-1) mod n + 1 {get the next cycle of the grid}
end {exit until after complete access over this cycle}
end;
l1: = 1;
for i: = 1 to k do l1: = l1 * m; {calc} k-th power of the m
l: = l + l1 {} is accumulated
end;
begin
writeln ( 'Input m, n =');
readln (m, n); {} input data
for i: = 1 to n do
for j: = 1 to n do a [i, j]: = (i-1) * n + j; {square initialized state}
b: = a;
xhj; {0 revolutions calculatedNumber of cycles of the section in a
state}
xz; {90 rpm}

xhj; {90 revolutions calculatedNumber of cycles of the section in a


state}
xz; {sub 90}

xhj; {180 revolutions calculatedNumber of cycles of the section in a


state}
xz; {sub 90}

xhj; {270 revolutions calculatedNumber of cycles of the section in a


state}
l: = l div 4;
writeln (l); {} output
readln
end.

In the above program, I stay away from the high-precision


calculations, and I say this not because of the content of the relationship.
If we consider carefully, you will find the solution to a problem can
also continue to optimize. Of n with different situations:
 n is an even number: 0 in turnWhen n2 is a circular section, 180

rpmWhen circulating section is n2 / 2 th, 90 rpmAnd 270 rpmWhen


circulating section is n2 / 4 th.
 n is an even number: 0 in turnWhen n2 is a circular section, 180

rpmWhen circulating section is (n2 + 1) / 2 th, 90 rpmAnd 270

rpmWhen circulating section is (n2 + 3) / 4 th.

Comprehensive look at these get: 0 in turnWhen n2 is a circular

section, 180 rpmWhen circulating section is [(n2 + 1) / 2] a, 90


rpmAnd 270 rpmWhen circulating section is [(n2 + 3) / 4] a. (Where
square brackets denote rounding) then get:

This results previously obtained

exactly.
After some analysis above, making a seemingly intractable problem
is clever solution, and the rest just do a bit of precision can be calculated.
By these few examples, we must Pólya principle of understanding
with 89 percent, and search method by contrast, it becomes clear
superiority. It not only greatly improve the time efficiency of the
program, even in the difficulty of programming is also on the decrease.
Therefore, we at the same time growing intelligence and experience, we
can not ignore the principle of knowledge. Intelligence and experience is
important, but even more to grasp the principles of ease. Therefore, we
are more than solving it, but also did not forget to learn the principles of
knowledge, non-stop to recharge, so that their level greater leap.

appendix (Program search method)


const
maxn = 10;
type
sqtype = array [1..maxn, 1..maxn] of byte;
var
n, total, m: integer;
sq: sqtype;
function big: boolean; (this test scheme is at the same equivalence class
maximum)
var
units: array [2..4] of sqtype; (a state record three kinds of rotation)
i, j, k: integer;
begin
for i: = 1 to n do
for j: = 1 to n do begin
units [2, j, n + 1-i]: = sq [i, j];
units [3, n + 1-i, n + 1-j]: = sq [i, j];
units [4, n + 1-j, i]: = sq [i, j]
end;
big: = false;
for k: = 2 to 4 do (for comparison)
for i: = 1 to n do begin
j: = 1;
while (j <= n) and (sq [i, j] = units [k, i, j]) do inc (j);
if j <= n then
if sq [i, j] <units [k, i, j]
then exit
else break
end;
big: = true
end;
procedure make (x, y: byte); (enumerate each grid in the coating color)
var i: integer;
begin
if x> n then begin
if big then inc (total);
exit
end;
for i: = 1 to m do begin
sq [x, y]: = i;
if y = n then make (x + 1,1) else make (x, y + 1)
end
end;
begin
writeln ( 'Input m, n ='); readln (m, n);
total: = 0;
make (1,1);
writeln (total); readln
end.

You might also like