**Principle of **

**Inclusion and Exclusion **

**•••• An Illustrative Example **

* Determine the number of integers n, 1*≤≤≤≤

*≤≤≤≤*

**n****100,**

**which are not divisible by 2, 3, 5.**

**Let S****=****{1, 2, …, 100} and N****=****|S|****=100. **

**Define three conditions as follows: **
**c**_{1}** :**** ****divisible by 2; **

**c**_{2}** :**** ****divisible by 3; **

**c**_{3}** :**** ****divisible by 5. **

**The answer is denoted by N(****c**_{1}**c**_{2}**c ), which is **_{3}**evaluated below. **

**N(c**_{1}**) = **_{└}**100/2**_{┘}** = 50; N(c**_{2}**) = **_{└}**100/3**_{┘}** = 33; **

**N(c**_{3}**) = **_{└}**100/5**_{┘}** = 20. **

**N(c**_{1}**c**_{2}**) = **_{└}**100/6**_{┘}** = 16; N(c**_{1}**c**_{3}**) = **_{└}**100/10**_{┘}** = 10; **

**N(c**_{2}**c**_{3}**) = **_{└}**100/15**_{┘}** = 6. **

**N(c**_{1}**c**_{2}**c**_{3}**) = **_{└}**100/30**_{┘}** = 3. **

**N(****c**_{1}**c**_{2}**c ) = N −**** _{3}** −−

**− (N(c**

_{1}**)**++++

**N(c**

_{2}**)**++++

**N(c**

_{3}**)) +**+++

**(N(c**

_{1}

**c**

_{2}**)**++++

**N(c**

_{1}

**c**

_{3}**)**++++

**N(c**

_{2}

**c**

_{3}**)) −**−−−

**N(c**

_{1}

**c**

_{2}

**c**

_{3}**)**

**= 100 −**−−**− (50**++++**33**++++**20) +**++**+ (16**++++**10**++++**6) −**−−**− 3 **

**= 26. **

**•••• The Principle **

**S :**** ****a set; N = |S| **

**c**_{1}**, c**_{2}**, …, c**_{t}** :**** ****conditions **

**N(c**_{i}**) :**** ****the number of elements in S that satisfy c**_{i}** **

**N(c**_{i}**c**_{j}**) :**^{ }**the number of elements in S that satisfy c**_{i}** and ****c**_{j}** (and perhaps some others) **

**N(****c**_{i}**) :**^{ }**the number of elements in S that do not satisfy **

**c**_{i}** (N(****c**_{i}* ) = N*−−−−

**N(c**

_{i}**))**

**N(****c**_{i}**c**_{j}**) :**^{ }**the number of elements in S that do not satisfy ****either of c**_{i}** and c**_{j}

**Theorem.**^{ }**The number of elements in S that satisfy none ****of c**_{1}**, c**_{2}**, …, c**_{t}** is equal to **

**N(****c**_{1}**c**_{2}**…****c**_{t}**) **

**=**

^{ }

^{N}

^{ }### − − − −

^{ }### ∑ ∑

### ∑ ∑

≤≤

≤≤

≤≤≤

≤**i****t****1**

**N(c**_{i}**)**^{ }

**+**

### ∑ ∑ ∑

### ∑

≤

≤

≤

≤

<

<<

<

≤

≤≤

≤**i****j****t****1**

**N(c**_{i}**c**_{j}**)**^{ }

### − − − −

^{ }### ∑ ∑

### ∑ ∑

≤

≤≤

≤

<

<<

<

<

<

<

<

≤

≤

≤

≤**i****j****k****t****1**

**N(c**_{i}**c**_{j}**c**_{k}**)**^{ }

**+**

^{ }**•••• •••• ••••**** **

**+**

^{ }**(−**−−−**1)**^{t}**N(c**_{1}**c**_{2}**…c**_{t}**). **

**When**** ****t****=****2, c**_{1}** →**→→**→ A**_{ }**and**_{ }**c**_{2}** →**→→**→ B. **

**N(****c**_{1}**c ) = **_{2}* |S| −*−−

*∪*

**− |A∪***∪*

**∪B|****= ** * |S| −*−−

*−−*

**− (|A| + |B| −***∩*

**− |A∩***∩*

**∩B|)****= ** * |S| −*−−

*∩∩*

**− (|A| + |B|) + |A∩**

**∩B|****When**** ****t****=****3, c**_{1}** →**→→**→ A,**_{ }**c**_{2}** →**→→**→ B,**_{ }**and**_{ }**c**_{3}** →**→* → C. *→

**N(****c**_{1}**c**_{2}**c ) = **_{3}* |S| −*−

*− ∪∪*

**− |A∪***∪∪*

**∪B∪**

**∪C|****= ** * |S| −*−

*− −*

**− (|A| + |B| + |C| −***− ∩∩*

**− |A∩***−*

**∩B| −***− ∩∩*

**− |A∩***−−−*

**∩C| −*** |B∩*∩∩

*∩*

**∩C| + |A∩***∩ ∩*

**∩B∩***∩*

**∩C|)****= ** * |S| −*−

*−*

**− (|A| + |B| + |C|) +*** (|A∩*∩∩

*∩*

**∩B| + |A∩***∩ ∩∩*

**∩C| + |B∩***−−−*

**∩C|) −*** |A∩*∩∩

*∩∩*

**∩B∩**

**∩C|****This theorem can be proved by induction on t. **

**Here we prove it by a combinatorial method. **

**Observation: **

* |A∪*∪∪

*−−*

**∪B| = |A| + |B| −***∩*

**− |A∩***∩*

**∩B|**

**a****1**

**= 1 + 0**−−−

**−**

**0**

**b****1**

**= 1 + 0**−−−

**−**

**0**

**c****1**

**= 1 + 1**−−−

**−**

**1**

**d****1**

**= 0 + 1**−−−

**−**

**0**

**e****0**

**= 0 + 0**−−−

**−**

**0**

**−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−**

**−**−

**4 ** **= 3 + 2 ** −−−**− ** **1 **

**Proof :** * For each x ∈*∈∈

**∈ S, we show that x contributes****the same count to each side of the equation.**

**N(****c**_{1}**c**_{2}**…****c**_{t}**) **

**=**

^{ N}

^{ }### − − − − ^{∑} ^{∑} ^{∑} ^{∑}

≤≤

≤≤

≤≤

≤≤**i****t****1**

**N(c**_{i}**)**^{ }

**+** ^{∑} ^{∑} ^{∑} ^{∑}

≤

≤≤

≤

<

<<

<

≤

≤≤

≤**i****j****t****1**

**N(c**_{i}**c**_{j}**)**^{ }

### − − − −

### ∑

### ∑

### ∑

### ∑

≤

≤

≤

≤

<

<

<

<

<

<<

<

≤

≤

≤

≤**i****j****k****t****1**

**N(c**_{i}**c**_{j}**c**_{k}**)**^{ }

**+**

^{ }^{••••}

^{ }^{••••}

^{ }^{••••}

^{ }**+**

**(−**−−−**1)**^{t}**N(c**_{1}**c**_{2}**…c**_{t}**). **

**Case 1.**** ****x satisfies none of the conditions. **

**x is counted once in N(****c**_{1}**c**_{2}**…****c**_{t}**) and N,**^{ }**but **
**not in the other terms. **

**Case 2. x satisfies r of the conditions. **

**(1)**** ****x contributes nothing to N(****c**_{1}**c**_{2}**…****c**_{t}**) **
**(2)**** ****x is counted once in N. **

**(3)**^{ }**x is counted (**

**1**

**r****) times in **

### ∑ ∑ ∑ ∑

≤

≤

≤

≤

≤

≤≤

≤**i****t****1**

**N(c**_{i}**). **

**(4)**** ****x is counted (**

**2**

**r****) times in **

### ∑ ∑ ∑ ∑

≤

≤

≤

≤

<

<

<

<

≤

≤≤

≤**i****j****t****1**

**N(c**_{i}**c**_{j}**). **

•

•

•

**x is counted (**

**r**

**r****) times in **

### ∑ ∑ ∑ ∑

**N(****i****1**

**c****c …****i****2**

**i****r**

**c ). **

⇒

⇒⇒

**⇒ left-hand side :**^{ }**0. **

**right-hand side :**^{ }**1 −**−−**− (**

**1**
**r****) +**++**+ (**

**2**

**r****) −**−−**− … +**++**+ (−**−−−**1)**^{r}**(**

**r****r****) **

**= (1**++++**(−**−−−**1))**^{r}** = 0. **

**Corollary.**^{ }**The number of elements in S that satisfy at ****least one of the conditions is N(c**_{1}** or c**_{2}** or … or c**_{t}**) = **
* N −*−−

**− N(****c**

_{1}

**c**

_{2}**…**

**c**

_{t}**).**

**Let**^{ }**S**_{0}** = N. **

**S**_{1}** = **

### ∑ ∑ ∑ ∑

≤

≤

≤

≤

≤

≤≤

≤**i****t****1**

**N(c**_{i}**). **

**S**_{2}** = **

### ∑ ∑ ∑ ∑

≤

≤≤

≤

<

<<

<

≤

≤

≤

≤**i****j****t****1**

**N(c**_{i}**c**_{j}**). **

•

•

•

**S**_{k}** = **

### ∑ ∑ ∑ ∑

**N(****i****1**

**c****c …****i****2**

**i****k**

**c ). **

**Theorem.**^{ }**The number of elements in S that satisfy exactly ****m of c**_{1}**, c**_{2}**, …, c**_{t}^{ }**is **

**E**_{m}** = S**_{m}** −**−−**− (**

**1**
+**1**
+
+
+

**m****)S**_{m+1}** + (**

**2**
+**2**
+
+
+

**m****)S**_{m+2}** −**−−**− … + **

** ****(−**−−−**1)**^{t−}^{−}^{−m}^{−} **(**

**m****t**

**t**

−

−

−

− **)S**_{t}**. **

**Proof.**^{ }* For each x*∈∈∈∈

**S, we show that x contributes the****same count to each side of the equation.**

**Case 1.**** ****x satisfies fewer than m conditions. **

**x is not counted on either side of the equation. **

**Case 2.**^{ }**x satisfies exactly m of the conditions. **

**x is counted once in E**_{m}** and once in S**_{m}**, but **
**not in S**_{m+1}**, S**_{m+2}**, …, S**_{t}**. **

**Case 3.**^{ }* x satisfies r (m*<<<<

*≤≤≤≤*

**r**

**t) of the conditions.****x is counted**^{ }**(**

**m**

**r****)**^{ }**times in S**_{m}**,**** ****(**

+**1**
+
+
+
**m**

**r****)**^{ }**times in **

**S**_{m+1}**,**** ****…,**** ****(**

**r**

**r****)**^{ }**times in S**_{r}**. **

**But,**^{ }**x contributes nothing to the other terms. **

⇒

⇒⇒

**⇒ ** **left-hand side :**^{ }**0. **

**right-hand side :**

** ** **(**

**m**

**r****) −**−**− **−

**(**

**1**
+**1**
+
++
**m**

**)**

^{(}+**1**
++
+
**m**

**r****) + **

**(**

**2**
+**2**
+
++
**m**

**)**

^{(}+**2**
+
+
+
**m**

**r****) −**−−−^{ }**…**^{ }**+ **

**(−**−−−**1)**^{r−}^{−}^{−}^{−m}**(**

**m****r**

**r**

−

−

−

− **)(**

**r****r****) **

**= **

**. ** **.**

**(left as an exercise)**

** ** **.**

**= 0. **

**Theorem.**^{ }**The number of elements in S that satisfy at ****least m of the t conditions is **

**L**_{m}** = S***_{m }*−−−−

**(**

−**1**

−

−

−
**m**

**m****)S**_{m+1}** + (**

**1**
**1**

−

−

−

−
+
+
+
+
**m**

**m****)S**_{m+2}** −**−−**− … + **

** ** **(**

−−^{−}−

**1**

**)**

^{ t−}^{−}

^{−}

^{−m}

^{(}**1**
**1**

−

−−

−

−

−−

−
**m**

**t****)S**_{t}**. **

**An inductive proof of this theorem was outlined as **
**problem 8 on page 401 of Grimaldi’s book. **

**For your reference, the following shows an alternative **
**proof that is based on a combinatorial method. **

*For each x*∈*S, we show that x contributes the same count to each side of the equation. *

*Case 1. x satisfies fewer than m conditions. *

*x is not counted on either side of the equation. *

*Case 2. x satisfies r (m*≤*r*≤*t) of the t conditions. *

*x is counted once in L** _{m}*,

^{r}*m*

*times in S** _{m}*,

1
*r*
*m*+

*times in S** _{m+1}*, …,

*r*
*r*

*times in S*_{r}*. But, x contributes nothing to any of the other terms in *
the equation.

Left-hand side: 1.

Right-hand side:

*r*
*m*

−

1 1

*m* *r*

*m*− *m*+

+ ^{1}

1 2

*m* *r*

*m* *m*

+

− +

−…+(−1)^{r−m}^{1}

1

*r* *r*

*m* *r*

−

−

= ^{(} ^{1)}

0 1

*r* *m* *k*

*m* *k* *m*

*k r m*

− +

∑ + −

≤ ≤ −

(−1)^{k }

= ^{(} ^{1)}

0

*r* *m* *k*

*m* *k*

*k r m* *k*

− +

∑ +

≤ ≤ −

(−1)^{k}* (assume m*−1+*k*≥0)

= 0

*r*
*m* *k*
*k r m*

*m*

∑ *k*

≤ ≤ − +

−

* (refer to Concrete Mathematics, 2*^{nd} edition, by Graham,
Knuth, and Patashnik, pp. 164, Eq. (5.14))

= ^{r}

*m* *k*
*k*

*m*

∑ *k*

+

−

(

*k*

−*m*

=*0 as k*<0, and

*m* *k*

*r*

+

=*0 as k*>*r*−*m) *

= *r* *m*

*r* *m*

−

− * (refer to Concrete Mathematics, 2*^{nd} edition, by Graham, Knuth, and
Patashnik, pp. 169, Eq. (5.23))

= 1.

*Since m*≥*0 and k*≥*0, we have m*=*0 and k*=*0 if m*−1+*k*<0.

*When m*=*0 and k*=0, the right-hand side is
0

*r*

=1.

**Ex.**^{ }**Compute the number of integer solutions to **

**x**_{1}** + x**_{2}** + x**_{3}** + x**_{4}** = 18,**^{ }**where 0**≤≤≤≤**x***_{i }*≤≤≤≤

**7 for 1**≤≤≤≤

*≤≤≤≤*

**i****4.**

**Let S be the set of integer solutions to **

**x**_{1}** + x**_{2}** + x**_{3}** + x**_{4}** = 18,**^{ }**where x***_{i }*≥≥≥≥

**0 for 1**≤≤≤≤

*≤≤≤≤*

**i****4.**

**Also, let c**_{i}** denote the constraint of x***_{i }*≥≥≥≥

**8.**

**Then,**^{ }**N(****c**_{1}**c**_{2}**c**_{3}**c**_{4}**) is the answer. **

**N = H(4, 18) = C(4****+18**−−−−**1, 18) = C(21, 18). **

**N(c**_{i}**) = H(4, 10) = C(13, 10). **

**N(c**_{i}**c**_{j}**) = H(4, 2) = C(5, 2). **

**N(c**_{i}**c**_{j}**c**_{k}**) = 0. **

**N(c**_{1}**c**_{2}**c**_{3}**c**_{4}**) = 0. **

**N(****c**_{1}**c**_{2}**c**_{3}**c**_{4}* ) = C(21, 18) −*−−

*××××*

**− C(4, 1)**

**C(13, 10) +***××××*

**C(4, 2)***−−*

**C(5, 2) −****− 0 + 0**

**= 246. **

**Ex.**^{ }**Compute the number of ways to permute a, b, c, …, ****y, z so that none of car, dog, pun, and byte occurs. **

**Let S be the set of all permutations of the 26 letters. **

**Let c**_{1}**, c**_{2}**, c**_{3}** and c**_{4}** denotethe conditions that the **
**permutations contain car, dog, pun, and byte, ****respectively. **

**Then,**^{ }**N(****c**_{1}**c**_{2}**c**_{3}**c**_{4}**) is the answer. **

**N = 26!. **

**N(c**_{1}**) = N(c**_{2}**) = N(c**_{3}**) = 24!;**^{ }**N(c**_{4}**) = 23!. **

**N(c**_{1}**c**_{2}**) = N(c**_{1}**c**_{3}**) = N(c**_{2}**c**_{3}**) = 22!;**^{ }**N(c**_{i}**c**_{4}**) = 21!.**

**N(c**_{1}**c**_{2}**c**_{3}**) = 20!;**^{ }**N(c**_{i}**c**_{j}**c**_{4}**) = 19!. **

**N(c**_{1}**c**_{2}**c**_{3}**c**_{4}**) = 17!. **

**N(****c**_{1}**c**_{2}**c**_{3}**c**_{4}**) = 26! −**−**− (3**− ××××**24!+23!) + (3**××××**22!+**_{ }**3**××××**21!) −**−**− (20!**− **+3**××××**19!) + 17!. **

**Ex.**^{ }* Given a positive integer n*≥≥≥≥

**2, the Euler’s phi function,**

**denoted by**φφφφ

**(n), is the number of integers m so that****1**≤≤≤≤* m*≤≤≤≤

**n and gcd(m, n)****=**

**1 (m, n are relatively prime).****For example,**** ^{ }**φφφφ

**(2)=1,**

**φφφφ**

^{ }**(3)=2,**

**φφφφ**

^{ }**(4)=2,**

^{ }**and**

**φφφφ**

^{ }**(5)=4.**

**Consider n = 1260 = 2**** ^{2}**××××

**3**

**××××**

^{2}**5**××××

**7 (**質因數分解質因數分解質因數分解質因數分解

**).**

**Let S = {1, 2, …, 1260}. **

φ φφ

φ**(1260) can be computed as follows. **

**Let c**_{1}**, c**_{2}**, c**_{3}**, c**_{4}** denotethe conditions that the integers **
**m are divisible by 2, 3, 5, 7, respectively. **

**Then,**** ^{ }**φφφφ

**(1260) = N(****c**

_{1}

**c**

_{2}

**c**

_{3}

**c**

_{4}**).**

**N = 1260. **

**N(c**_{1}**) = 1260/2 = 630;**^{ }**N(c**_{2}**) = 1260/3 = 420; **

**N(c**_{3}**) = 1260/5 = 252;**^{ }**N(c**_{4}**) = 1260/7 = 180. **

**N(c**_{1}**c**_{2}**) = 1260/6 = 210;**^{ }**N(c**_{1}**c**_{3}**) = 1260/10 = 126; **

**N(c**_{1}**c**_{4}**) = 1260/14 = 90;**^{ }**N(c**_{2}**c**_{3}**) = 1260/15 = 84; **

** ** **N(c**_{2}**c**_{4}**) = 1260/21 = 60;**^{ }**N(c**_{3}**c**_{4}**) = 1260/35 = 36. **

**N(c**_{1}**c**_{2}**c**_{3}**) = 1260/30 = 42;**^{ }**N(c**_{1}**c**_{2}**c**_{4}**) = 1260/42 = 30; **

**N(c**_{1}**c**_{3}**c**_{4}**) = 1260/70 = 18;**^{ }**N(c**_{2}**c**_{3}**c**_{4}**) = 1260/105 = 12.**^{ }

**N(c**_{1}**c**_{2}**c**_{3}**c**_{4}**) = 1260/210 = 6. **

**N(****c**_{1}**c**_{2}**c**_{3}**c**_{4}**) = 1260 −**−**− (630**− **+420+252+180) + **
**(210+126+90+84+60+36) −**−**− **−
**(42+30+18+12) + 6 **

**= 288.**

**In general, suppose n =****p**_{1}^{e}^{1}**p**_{2}^{e}^{2}**…** **p**_{t}^{e}^{t}**(**質因數分解質因數分解質因數分解質因數分解**). **

**Then,**** ^{ }**φφφφ

^{(n) =}

^{ }*××××*

**n****(1**−−−−

**1**

**1**

**p****)**××××**(1**−−−−

**2**

**1**

**p****)**×××**× … ×**×××**(1**−−−− ^{1}**p****t****). **

**For example,**^{ }**when**** *** n = 1260, *
φ

φφ

φ^{(1260) =}^{ }** ^{1260}**××××

**(1**−−−−

^{1}**2)**××××**(1**−−−− ^{1}

**3)**××××**(1**−−−− ^{1}

**5)**××××**(1**−−−− ^{1}**7) **

**= 288. **

**Another description of Euler’s formula: **

**Suppose that n is a positive integer and p**_{1}**, p**_{2}**, …, **
**p**_{r}** are distinct prime numbers, where n****>****p**_{i}** for all **
**1**≤≤≤≤* i*≤≤≤≤

**r.****Let**^{ }**F(n) = |{m****| 1**≤≤≤≤* m*≤≤≤≤

**n is an integer and**

**gcd(m, p**

_{i}**)=1 for all 1**≤≤≤≤

*≤≤≤≤*

**i**

**r}|.****Then, F(n) is equal to ****f(n)**^{ }**=**^{ }* n*××××

**(1**−−−−

**1**

**1**

**p****)**××××**(1**−−−−

**2**

**1**

**p****)**×××**× … ×**×××**(1**−−−− ^{1}**p****r****), **
**if**^{ }**f(n)**^{ }**is an integer. **

**Ex.** **Suppose that**^{ }**n****=23,**^{ }**p**_{1 }**=2,**^{ }**and**^{ }**p**_{2 }**=3**^{ }**(i.e., r****=2). **

**There are 8 integers in {1, 2, …, 23} that are relatively **
**prime to both 2 and 3. They are 1, 5, 7, 11, 13, 17, 19, **
**and 23. **

**f(n)**^{ }**=**^{ }* n*××××

**(1**−−−−

^{1}**2)**××××**(1**−−−− ^{1}**3)**^{ }**=**^{ }

**3**
**n****. **
**f(23) is not an integer **

**We first compute**^{ }**f(21)****=7**** ****(or f(24)****=8),**^{ }**and then **
**obtain**^{ }**F(23)****=****F(21)****+1=****f(21)****+1=8**** ****(or**^{ }**F(23)****=**_{ }**F(24)****=****f(24)****=8),**^{ }**where 1 indicates the integer 23. **

**Ex.**^{ }**Six married couples are to be seated at a circular **
**table.**^{ }**In how many ways can they be arranged **
**so that no wife sits next to her husband? **

**Let c**_{i}** denote****the condition that couple i are ****neighboring, where 1**≤≤≤≤* i*≤≤≤≤

**6.**

**The answer is**^{ }**N(****c**_{1}**c**_{2}**…****c**_{6}**). **

**N =**^{12!}

**12** **= 11!. **

**N(c**_{i}**) =** ^{11!}

**11** ××××**2 = 2**××××**10!. **

**N(c**_{i}**c**_{j}**) =** ^{10!}

**10** ××××**2**^{2}** = 2**** ^{2}**××××

**9!.**

**Similarly,**^{ }**N(c**_{i}**c**_{j}**c**_{k}**) = 2**** ^{3}**××××

**8!,**

^{ }

**N(c**

_{i}

**c**

_{j}

**c**

_{k}

**c**

_{l}**) = 2**

**××××**

^{4}**7!,**

**N(c**

_{i}

**c**

_{j}

**c**

_{k}

**c**

_{l}

**c**

_{r}**) = 2**

**××××**

^{5 }**6!,**

^{ }

**N(c**

_{i}

**c**

_{j}

**c**

_{k}

**c**

_{l}

**c**

_{r}

**c**

_{s}**) = 2**

**××××**

^{6 }**5!.**

**N(****c**_{1}**c**_{2}**…****c**_{6}**) = 11! −**−* − C(6, 1)*− ××××

**2**××××

*××××*

**10! + C(6, 2)****2**

**××××**

^{2}**9!**

−−

−* − C(6, 3)*××××

**2**

**××××**

^{3}*××××*

**8! + C(6, 4)****2**

**××××**

^{4}**7!**

−−

−* − C(6, 5)*××××

**2**

**××××**

^{5 }*××××*

**6! + C(6, 6)****2**

**××××**

^{6}**5!**

**= 12,771,840. **

**Ex.**^{ }**How many ways are there to connect five vertices **
**a, b, c, d and e so that none of them is isolated? **

** ** **(O) ** **(O) ** **(X) ** **(X) **

**Let c**_{1}**, c**_{2}**, c**_{3}**, c**_{4}** and c**_{5}** denotethe conditions that **
**vertices a, b, c, d and e are isolated, respectively. **

**The answer is**^{ }**N(****c**_{1}**c**_{2}**…****c**_{5}**). **

**N = 2**^{10}^{ }**(at most 10 edges among five vertices). **

**N(c**_{i}**) = 2**^{6}**. **
**N(c**_{i}**c**_{j}**) = 2**^{3}**. **
**N(c**_{i}**c**_{j}**c**_{k}**) = 2**^{1}**. **

**N(c**_{i}**c**_{j}**c**_{k}**c**_{l}**) = N(c**_{i}**c**_{j}**c**_{k}**c**_{l}**c**_{r}**) = 2**^{0}**. **

**N(****c**_{1}**c**_{2}**…****c**_{5}**) = 2**^{10}** −**−* − C(5, 1)*− ××××

**2**

^{6}*××××*

**+ C(5, 2)****2**

^{3}−−

−* − C(5, 3)*××××

**2**

^{1}*××××*

**+ C(5, 4)****2**

^{0}−−

−* − C(5, 5)*××××

**2**

^{0}**= 768. **

**Ex.**^{ }**For the example above, how many ways are there to **
**connect five vertices a, b, c, d and e so that exactly ****two of them are isolated? **

**The answer is E**_{2}** = S**_{2}** −**−* − C(3, 1)*− ××××

**S**

_{3}*××××*

**+ C(4, 2)**

**S**

_{4}

−−

−* − C(5, 3)*××××

**S**

_{5 }* = C(5, 2)*××××

**2**

^{3}**−**−−

*××××*

**− C(3, 1)***××××*

**C(5, 3)****2**

^{1}

*××××*

**+ C(4, 2)***××××*

**C(5, 4)****2**

^{0 }−−

−* − C(5, 3)*××××

*××××*

**C(5, 5)****2**

^{0 }**= 80 −**−−**− 60 + 30 −**−−**− 10 **

**= 40. **

**•••• Derangements **

**An arrangement of 1, 2, …, n is called a derangement, ****if 1 is not at the first place (its natural position),**^{ }**2 is not **
**at the second place (its natural position), …, and n is not ****at the nth place (its natural position). **

**Consider n****=10,**** ****and let c**_{i}** denote the condition that **
**integer i is at the ith place,**^{ }**where 1**≤≤≤≤* i*≤≤≤≤

**10.**

**The number of derangements of 1, 2, …, 10 is **
**N(****c**_{1}**c …**_{2}**c ) =**_{10}** ****10! −**−−**− (**

**1**

**10****)9! +**+**+ (**+

**2**

**10****)8! −**−−**− … +**+++**(**

**10**

**10****)0! **

**=**^{ }**1334960. **

**Ex. There are seven books undergoing a two-round **
**review process of seven reviewers.**^{ }**Each book is **
**reviewed by two distinct reviewers.**^{ }**In how many **
**ways can these books be reviewed? **

**There are 7! ways for the first-round review. **

**There are d**_{7}** ways for the second-round review, **
**where d**_{7}** is the number of derangements of 1, 2, **

**…, 7. **

**The answer is 7!**××××**d**_{7}**. **

### ×

### × ×

### ×

_{ :}

_{ }

_{rook (車}_{車}

_{車) }_{車}

**•••• Rook Polynomials **

**Problem :**^{ }**Given a chessboard C of arbitrary shape ****and size, determine the number r**_{k}** of ways of placing k ****nontaking rooks on C. **

**…** **…**

**… ** ××××

**… … … **

**…**

**C :**

** ****r**_{1}** = 6,**^{ }**r**_{2}** = 8,**^{ }**r**_{3}** = 2 **
**r**_{k}** = 0**** *** for k*≥≥≥≥

**4**

** **

**Let r**_{0}** = 1. **

**rook polynomial R(C, x) = **

### ∑ ∑ ∑ ∑

^{∞}

^{∞}

^{∞}

^{∞}

=

==

**=0**
**i**

**r**_{i}**x**^{i}

** ** ** = 1+****6x****+****8x**^{2}**+****2x**^{3 }

**C**_{2}** :**
**C**_{1}** :**

**C : **

**R(C, x) = 1****+****11x****+****40x**^{2}**+****56x**^{3}**+****28x**^{4}**+****4x**^{5}**R(C**_{1}**, x) = 1****+****4x****+****2x**^{2}

**R(C**_{2}**, x) = 1****+****7x****+****10x**^{2}**+****2x**^{3}** **

**C**_{1 }**and C**_{2}** are “disjoint” (no square in the same row or **
**column) **

⇒⇒

⇒**⇒ R(C, x) = R(C**_{1}**, x)**

### ⋅⋅⋅⋅

^{R(C}**2**

**, x)****Count r**_{3}** in C as follows. **

**Case 1.**^{ }**All three rooks are placed on C**_{2 }**:**^{ }**2 ways **
**Case 2.**^{ }**Two rooks are placed on C**_{2 }**and one rook is **

**placed on C**_{1}** :**^{ }**10**××××**4 = 40 ways **

**Case 3.**^{ }**One rook is placed on C**_{2 }**and two rooks are **
**placed on C**_{1}** :**^{ }**7**××××**2 = 14 ways **

**r**_{3}** = 2+40+14 = 56 **

**Compute the coefficient r**_{3}** of x**^{3}** in R(C**_{1}**, x)**

### ⋅⋅⋅⋅

^{R(C}**2**

**, x) :**

**R(C**

_{1}

**, x)**### ⋅⋅⋅⋅

^{R(C}**2**

**, x)****=**** ****(1+****4x****+****2x**^{2}**)**

### ⋅⋅⋅⋅

^{(1}^{+}

^{7x}

^{+}

^{10x}

^{2}

^{+}

^{2x}

^{3}

^{) }**=**** ****. . . + 1**

### ⋅⋅⋅⋅

^{2x}

^{3}

^{ + 4x}### ⋅⋅⋅⋅

^{10x}

^{2}

^{ + 2x}

^{2}### ⋅⋅⋅⋅

**7x + . . .****=**** ****. . . + (1**

### ⋅⋅⋅⋅

^{2}^{+}^{4}### ⋅⋅⋅⋅

^{10}^{+}^{2}### ⋅⋅⋅⋅

^{7)x}

^{3}**+ . . .**

**Case 1**

**Case 2**

^{ }**Case 3**

**If C is a chessboard made up of pairwise disjoint ****subboards C**_{1}**, C**_{2}**, …, C**_{n}**, then **

**R(C, x) = R(C**_{1}**, x)**

### ⋅⋅⋅⋅

^{R(C}**2**

**, x)**### ⋅⋅⋅⋅

^{ }

^{…}

^{ }### ⋅⋅⋅⋅

^{R(C}

**n**

**, x).****Let r**_{k}**(C) denote the number of ways of placing k ****nontaking rooks on the chessboard C. **

**C: **

**r**_{k}**(C) consists of the following two parts. **

∗∗∗

**∗ **

**C**_{s}** : **

**C**_{e}** :****(C**_{e}** is obtained from C by deleting ****the designated square.) **

**1.**^{ }**A rook on the square designated by “∗**∗∗**∗”. **

**(C**_{s}** is obtained from C by deleting the ****row and the column containing the **
**designated square.) **

**r**_{k−}_{−}_{−1}_{−} **(C**_{s}**) is included in r**_{k}**(C). **

**2****. ****No rook on the designated square. **

**r**_{k}**(C**_{e}**) is included in r**_{k}**(C). **

**Therefore,** **r**_{k}**(C) = r**_{k−}_{−}_{−1}_{−} **(C**_{s}**) + r**_{k}**(C**_{e}**),**** ****and **
**R(C, x) = xR(C**_{s}**, x) + R(C**_{e}**, x). **

**= x**

### ⋅⋅⋅⋅

∗

∗∗

∗

**+**_{ }

∗

∗∗

∗

**= x**^{2}

### ⋅⋅⋅⋅

^{+}^{x}### ⋅⋅⋅⋅

^{+}^{x}### ⋅⋅⋅⋅

**+**** _{ }** ∗∗∗∗

**= x**^{2}

### ⋅⋅⋅⋅

^{+}^{2x}### ⋅⋅⋅⋅

^{+}^{x}### ⋅⋅⋅⋅

_{+}

_{ }**= (x**^{2}**+ x)**

### ⋅⋅⋅⋅

^{+ (2x}^{+ 1)}### ⋅⋅⋅⋅

**Ex. **

**= (x**^{2}**+****x)**

### ⋅⋅⋅⋅

^{ (1}^{+}

^{2x)}

^{+}

^{(2x}

^{+}^{1)}### ⋅⋅⋅⋅

^{(x}

^{2}

^{+}

^{3x + 1) }**= 1+****6x****+****10x**^{2}**+****4x**^{3}**. **

∗∗∗

**∗ **

**C : ****Ex.**^{ }

**Determine the number of ways of placing four nontaking **
**rooks on the unshaded area of C. **

**Let c**_{i}** be the condition that a rook is placed on the shaded **
**area of row i. **

**N(****c**_{1}**c**_{2}**c**_{3}**c**_{4}**) = S**_{0 }**–****S**_{1 }**+****S**_{2 }**–****S**_{3 }**+****S**_{4}

** = 5!–****r**_{1 }

### ⋅⋅⋅⋅

^{4!}^{+}

^{r}**2**

### ⋅⋅⋅⋅

^{3!}^{–}

^{r}**3**

### ⋅⋅⋅⋅

^{2!}^{+}

^{r}**4**

### ⋅⋅⋅⋅

^{1!, }**where**^{ }**R(the shaded area of C, x) **

**= (1+****3x****+****x**^{2}**)**

### ⋅⋅⋅⋅

^{(1}^{+}

^{4x}

^{+}

^{3x}

^{2}

^{) }**= 1+****7x****+****16x**^{2}**+****13x**^{3}**+****3x**^{4}** = 1+****r**_{1}**x****+****r**_{2}**x**^{2}**+****r**_{3}**x**^{3}**+****r**_{4}**x**^{4}**. **

∴

∴

∴

∴^{ }**N(****c**_{1}**c**_{2}**c**_{3}**c**_{4}**) = 5!–7**

### ⋅⋅⋅⋅

^{4!}^{+}^{16}### ⋅⋅⋅⋅

^{3!}^{–}^{13}### ⋅⋅⋅⋅

^{2!}^{+}^{3}### ⋅⋅⋅⋅

^{1! }**= 25. **

**Ex. Four people, denoted by R**_{1}**, R**_{2}**, R**_{3}** and R**_{4}**, are **
**assigned to five tables, denoted by T**_{1}**, T**_{2}**, T**_{3}**, T**_{4}** **
**and T**_{5}**, in a wedding reception.**^{ }**In how many **
**ways can they be assigned to four distinct tables, **
**subject to the following four restrictions: **

**(a)**** R****1**** is not assigned to T**_{1}** or T**_{2}**; **
**(b)**** R****2**** is not assigned to T**_{2}**; **

**(c)**** R****3**** is not assigned to T**_{3}** or T**_{4}**; **
**(d)**** R****4**** is not assigned to T**_{4}** or T**_{5}**. **

**The answer is 25, as computed in the example above. **

**Ex. Two dice, denoted by R and G, are rolled six times. **

* Under the condition of (R, G)*∉∉∉∉

**{(1, 2), (2, 1), (2, 5),**

**(3, 4), (4, 1), (4, 5), (6, 6)}, what is the probability**

**that all six values 1, 2, …, 6 occur for both R and G?****Consider the following left chessboard, where the row **
**(column) labels represent the outcome on R (G). **

**The right chessboard is obtained by relabeling the **
**rows and columns, where the seven shaded squares **
**constitute four pairwise disjoint subboards. **

**Therefore,**^{ }**r(C, x) = (1****+****4x****+****2x**^{2}**)**××××**(1+****x)**^{3}

**= 1+****7x****+****17x**^{2}**+****19x**^{3}**+****10x**^{4}**+****2x**^{5}**. **

**The probability is**** ****P =**^{6!}_{6}**29**

×**S**

×

×

× **,**** ****where there are 6! ways **
**for R to occur 1, 2, …, 6 and S is the number of ways ****for G to occur 1, 2, …, 6 under the condition. **

**For example,**^{ }**(1, ?), (2, ?), (3, ?), (4, ?), (5, ?), (6, ?)**^{ }**and **
**(4, ?), (5, ?), (6, ?), (1, ?), (2, ?), (3, ?)**^{ }**are two ways for R ****to occur**^{ }**1, 2, 3, 4, 5, 6.**^{ }

**Then,**^{ }**each way for the former to occur**^{ }**1, 2, 3, 4, 5, 6 **
**for G,**^{ }**e.g.,**^{ }**(1, 6), (2, 2), (3, 3), (4, 4), (5, 5), (6, 1), **

**uniquely corresponds to a way for the latter to occur **
**1, 2, 3, 4, 5, 6**^{ }**for G,**^{ }**e.g.,**^{ }**(4, 4), (5, 5), (6, 1), (1, 6), **
**(2, 2), (3, 3),**^{ }**and vice versa. **