You are on page 1of 15

Basic Counting

Techniques
PHƯƠNG PHÁP ĐẾM
Product Rule
 You own 5 shirts and 4 pants. Then there are 5 × 4 = 20
different ways you can get dressed tomorrow.
 A test consists of 6 mutiple-choice questions. Each
question has 4 possible answers. How many ways to
answer all 6 questions?
 If there are n ways of doing something, and m ways of
doing another thing after that, then there are n×m ways
to perform both of these actions.
 |A×B| = |A|×|B|
Sum Rule
 If there are n choices for one action, and m choices for another
action and the two actions cannot be done at the same time, then
there are n+m ways to choose one of these actions (assuming the
elements of A and B are distinct)
 if A ∩ B = Ø, then |A ∪ B| = |A| + |B|.
 Calvin wants to go to Milwaukee. He can choose from 3 bus
services or 2 train services to head from home to downtown
Chicago. From there, he can choose from 2 bus services or 3 train
services to head to Milwaukee. How many ways are there for Calvin
to get to Milwaukee?
Example

 He has 3 + 2=5 ways to get to downtown Chicago. (Rule of sum)


 From there, he has 2+3=5 ways to get to Milwaukee. (Rule of sum)
 Hence, he has 5×5=25 ways to get to Milwaukee in total. (Rule of product)​

https://brilliant.org/wiki/rule-of-sum-and-rule-of-product-problem-solving/
Example
 A restaurant offers 5 choices of appetizer course, 10
choices of the main course and 4 choices of dessert
course. A customer can choose to eat just one course, or
two different courses, or all three courses. Assuming that
all food choices are available, how many different
possible meals does the restaurant offer?
 Note: When you eat a course, you only pick one of the
choices.
Example
 A restaurant offers 5 choices of appetizer course, 10 choices of the main course and 4
choices of dessert course. A customer can choose to eat just one course, or two
different courses, or all three courses. Assuming that all food choices are available,
how many different possible meals does the restaurant offer?
 Note: When you eat a course, you only pick one of the choices.

 Solution:
 1 course: 5 + 10 + 4 = 19 options
 2 courses:
 Appetizer, main: 5 * 10 = 50 options
 Appetizer, dessert: 5 * 4 = 20 options
 Main, dessert: 10 * 4 = 40 options
 3 course: 5 * 10 * 4 = 200 options
 Total: 19 + 50 + 20 + 40 + 200 = 329 options
Inclusion-Exclusion Principle

 The sum rule is a special case of a more general


formula when the two sets can overlap, namely:
|A ∪ B| = |A| + |B| - |A ∩ B|
 The inclusion-exclusion formula generalizes to
three sets and beyond in a natural way:
|A ∪ B ∪ C| = ?
 |A ∪ B ∪ C| = |A| + |B| + |C| - |A ∩ B| -
|A ∩ C| - |B ∩ C| + |A ∩ B ∩ C|
Inclusion-Exclusion Principle

 100 people asked if they have a cat or dog as a pet.


 55 answered yes for cat
 58 answered yes for dog
 20 people checked yes for both cat and dog.
 How many people have a cat or a dog?
Inclusion-Exclusion Principle

 100 people asked if they have a cat or dog as a pet.


 55 answered yes for cat
 58 answered yes for dog
 20 people checked yes for both cat and dog.
 How many people have a cat or a dog?

 Solution:
 A= 55; B= 58
 Answer = 55 + 58 − 20 = 93
How many integers in {1,...,100} are not divisible by
2, 3 or 5?
How many integers in {1,...,100} are not divisible by
2, 3 or 5?

 S = {1,...,100} 
 P1, P2, P3 the property that an integer is divisible by 2, 3, 5
 Ai be the subset of S whose elements have property Pi
 |A1| = 50, |A2| = 33, and |A3| = 20
 There are 16 of these integers divisible by 6, 10 divisible by 10, and 6
divisible by 15. Finally, there are just 3 integers divisible by 30
 The number of integers not divisible by any of 2, 3 or 5 is given by:
100 − (50 + 33 + 20) + (16 + 10 + 6) − 3 = 26.

https://brilliant.org/wiki/principle-of-inclusion-and-exclusion-pie/
10882
10882.*

 3 people having 100 numbers with label(1-100) on it 


 Given intersection of A ∩ B, A ∩ C, B ∩ C of the same
label
 Find the range of A ∩ BC
 max is min(A ∩ B,A ∩ C,B ∩ C)
X + Y + Z + K ≤ 100
--> X + K + Y + K + Z + K -2*K ≤ 100
--> A^B + A^C + B^C – 2K ≤ 100
 K ≥ (( A^B + A^C + B^C)-100)/2
Dembuoc.*
dembuoc.*

steps max_reachable_number increase


0 0 (0)
1 1 (1) +1
2 2 (11) +1
3 4 (121) +2
4 6 (1221) +2
5 9 (12321) +3
6 12 (123321) +3
7 16 (1234321) +4
8 20 (12344321) +4

• f(2n) = n(n + 1) for even step


• f(2n + 1) = (n + 1)2 for odd steps
• The numbers from f(k - 1) + 1 to f(k) can be reached by using k steps

You might also like