Stars and Bars Introduction To Competition Math

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 36

Stars and Bars for Computational Contests

Akshay A.∗
May 2020

Preface

In this handout, we will be covering virtually everything necessary


to ace any stars and bars problem. Some will stretch outside the
regular realm of stars and bars, although the way you internalize
it, pictorially, is very similar. One prerequisite
 
to comprehend this
n
handout is an understanding of k notation. Although this
technique is theoretically very simple, the thinking involved can be
used in all sorts of applications. You will notice that partitions are
also included in this paper, as many aspects of the techniques and
applications of stars and bars overlap. Also, I would like to thank
Nikenissan for taking his time to help edit this handout and
improve the quality. You can find his contact information in the
acknowledgments of this handout.

∗ MathCounts145 on AoPS - can be contacted using mathgeek145@gmail.com

1
Akshay A. CONTENTS

Contents

1 Defining Stars and Bars 3


1.1 Stars and Bars as a Picture . . . . . . . . . . . . . . 4
1.2 Deriving the Formulas . . . . . . . . . . . . . . . . . 8
1.3 The Concept of Partitions . . . . . . . . . . . . . . . 11

2 Problems 20
2.1 Problems . . . . . . . . . . . . . . . . . . . . . . . . . 20
2.2 Hints . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
2.3 Solutions . . . . . . . . . . . . . . . . . . . . . . . . . 24

3 Ending Remarks 36
3.1 Acknowledgements . . . . . . . . . . . . . . . . . . . 36
3.2 Contact Information . . . . . . . . . . . . . . . . . . 36

2
Akshay A. 1 DEFINING STARS AND BARS

1 Defining Stars and Bars

Essentially speaking, stars and bars is a method where you


can partition identical items to distinguishable objects. Yet, what
accurately represents an identical and distinct object? In a rather
broad spectrum of counting and probability methods, there are
four large subsets. Set balls as the object and the item we are
partitioning the balls into as boxes. The four configurations of
balls and boxes are listed below:

1. Balls are identical and boxes are distinguishable.

2. Balls are identical and boxes are identical.

3. Balls are distinguishable and boxes are identical.

4. Balls are distinguishable and boxes are distinguishable.

In this handout, we will first focus on case 1 and then on case


2.
After I present the initial problem we’ll be tackling, you
should be able to develop sufficient knowledge to be able to solve it
at the end.

Example 1.0.1 Dr.Evil’s 5th grade class has 6 students.


Dr.Evil has 6 identical candies to give to the 6 students. How-
ever, as Dr.Evil is evil, he doesn’t necessarily want to give 1
to each student. How many ways are there for him to give
these candies to the students?

When reading this problem, it’s easy to notice two things.


First, this follows our guideline of identical balls and

3
Akshay A. 1 DEFINING STARS AND BARS

distinguishable boxes. In this case, the candies are identical, and


evidently, the students are distinguishable.
Secondly, if we were to physically count them by listing them
all out, it would (a) be extremely time-consuming and (b) be
extremely easy to miscount or make a stupid mistake. Therefore,
we need a more efficient solution. Let us now start exploring stars
and bars!

Remark 1.0.1 Some people call stars and bars “stones and
sticks” as well as “ball and urn”. Just note these so that you
don’t get confused.

1.1 Stars and Bars as a Picture

To start getting an idea of how to use stars and bars, let’s


utilize example 1.0.1. Let us imagine each of the identical candies
to be circles/balls as shown below.

Let us imagine putting lines or bars in between gaps of the


circles to see how many candies every student gets. A small
example is demonstrated below.

In the configuration above, we have divided the candies into


six partitions using five lines. Each partition has size one, meaning
every student has one candy. Now, let us look at another
configuration and base some conclusions on that.

4
Akshay A. 1 DEFINING STARS AND BARS

In the configuration shown above, we again have divided the


candies into six partitions using five lines. Yet, the partition sizes
are varying, meaning that each student gets a varied amount of
candies. The number of candies are 1, 0, 2, 0, 2, 1 per student from
left to right.
These two configurations inform us of several things. First of
all, we can now be sure that the balls are identical, and that the
boxes are distinguishable. The balls are identical because we are
partitioning the interchangeable balls. In addition, with the
sticks, we can repeatedly change the candy distribution (to
account for all the various cases). For example, in the second
configuration shown, the distribution of candies is 1-0-2-0-2-1, yet
the distribution could also be 2-0-1-2-1-0. Here, we see that the
individual numbers can be identical, yet the order is different.
Therefore, the boxes have to be distinctive for us to use this
technique.
Adding to above, putting the bars in different gaps between
the balls will yield us every possible arrangement, thus ensuring we
won’t be over-counting or under-counting. Now, there will be two
solutions presented to example 1.0.1. The initial solution will be a
“bogus” solution, which is an incorrect solution, but it will indicate
a common mistake. The second solution will accurately utilize the
strategy we developed above.

5
Akshay A. 1 DEFINING STARS AND BARS

Example 1.0.1 Dr.Evil’s 5th grade class has 6 students.


Dr.Evil has 6 identical candies to give to the 6 students. How-
ever, as Dr.Evil is evil, he doesn’t necessarily want to give 1
to each student. How many ways are there for him to give
these candies to the students?

Solution 1 (Bogus): We can now try to use our new


discoveries to this problem. Let’s draw all 6 balls, representing the
6 candies.

Now, let us mark all the gaps in which we can insert the lines
as we did above. Note that any person can have 0 candies, which
is why we have to count the gap to the left of the leftmost ball and
the gap to the right of the rightmost ball.

In the representation above, we can see that we marked 7 gaps


for us to put the lines. Also, as we previously saw, we need 5 lines
to split the row of candies into 6 different parts. Therefore, we
have
 
to choose 5 out of 7 gaps to put the lines. The answer is then
7
5
= 21 .

So, why is this solution incorrect? We can look at the 2nd


configuration we made on page 5. There, we put two lines on the
same gap to allow anyone to get 0 candies. In the gaps we
identified in solution 1, only the first and last student could get 0
candies, meaning we severely undercounted.

6
Akshay A. 1 DEFINING STARS AND BARS

However, adding in the extra gaps is not very easy. Every gap
between the balls could have up to 5 (all of the lines) lines inside
of it. As we initially had seven slots, we would now have 7 · 5 = 35
slots. We now face an annoying, yet true conundrum. If we have
five gaps but only put one line, it’s identical if the line is on the 1st
gap, the 2nd gap, the 3rd gap, the 4th gap, or the 5th gap.
The diagram below shows an example of this being true.
Assume the gaps are in between two balls.

Putting just one line in the first slot like that is equivalent to
putting just one line on another gap, as shown below.

Therefore, using it like this will severely overcount the number


of cases. So how do we make sure we don’t under count like we did
in solution 1, but also not over count like we’re doing here.
Instead, we could look at the lines a little bit differently. Instead of
putting lines, let’s put filled circles, as shown below.

Let’s try to simulate one of the configurations using this


picture.

7
Akshay A. 1 DEFINING STARS AND BARS

In this configuration, the filled in markers separated the


candies into 0-3-2-0-1-0. Therefore, with this method, we will be
able to count everything, including 0’s. So we now know the
correct solution 2.
Solution 2: Let us first draw out our filled circles and regular

circles.

As we saw above, we just need to find the number of ways we can


arrange the filled circles. As there are 11 total

positions and 5
11
filled circles, the total number of ways is 5 = 462 . And 462 is
indeed the correct answer.

1.2 Deriving the Formulas

Now that we have a decent understanding of what stars and


bars is and how to visualize it, let us try to use these techniques to
generalize a formula.

Remark 1.2.1 Remember, deriving formulas is much more


important than just memorizing them. If you don’t under-
stand how you got to them, you will definitely forget them
during the test.

We are going to start by deriving two formulas. To do so, we


will be using problems to lead our thinking.

8
Akshay A. 1 DEFINING STARS AND BARS

Example 1.2.1 How many ways are there for Jones to give
eight coins to his four friends such that each of his friends gets
at least one coin?

In this question, we will try to use our stars and bars strategy.
However, we will need to be a little careful because everyone gets
at least one coin.

Solution 1: Let us initially draw eight balls to represent the


eight coins.

Let’s mark all the gaps which we can use, yet we have to be
careful not to mark extra gaps, as no person can get 0 coins.

Just like the previous problem, we know we have to use three


lines to break the eight balls into four different pieces. As we have
8 −

1 = 7 different gaps we can put them in, the answer is
7
3
= 35 .

WARNING: Make sure you reread the problem and mark


the correct number of gaps. If you had counted the outer
gaps, the answer would’ve been incorrect.

Although this strategy is remarkably powerful, it isn’t difficult

9
Akshay A. 1 DEFINING STARS AND BARS

to make stupid mistakes. You should understand exactly what the


question is asking, as it ensures you will fulfill all the restrictions in
the problem.

We have also derived the formula for the number of ways to


split n identical items into k different groups, such that every
group has at least 1 item. We noticed that there aren −1 gaps
and k − 1 lines we have to put in those gaps, so it’s n−1
k−1

Theorem 1.2.1 If we have to split n identical items into k


distinguishable groups, where every group

has at least one
n−1
item, the number of ways to do so is k−1 .

Now that we’ve derived this, we need to derive the formula if


every group can have 0 or more items. As example 1.0.1 covered
this, we will directly refer to it.

We recall that we used the shaded circles to split up the


candies in example 1.0.1. We had k − 1 shaded circles for splitting
into k groups. There were also n unfilled circles representing the
candies. Thus, the total number of gaps are n + k − 1. Asthere
are k − 1 shaded balls, the total number of ways is n+k−1
k−1
.

Theorem 1.2.2 If we need to split n identical items to k


distinguishable groups, where each group can have0 or more

items, the total number of ways to distribute it is n+k−1
k−1
.

10
Akshay A. 1 DEFINING STARS AND BARS

This is essentially what stars and bars is. In the next section,
we’ll look at the concept of partitions, which sometimes overlaps
with stars and bars problems.

1.3 The Concept of Partitions

First, what exactly are partitions, and how are they different
from stars and bars? As usual, we will resort to a problem.

Example 1.3.1 How many ways can 3 positive numbers sum


to 10 if the order of the addends doesn’t matter? By order of
the addends doesn’t matter, it means 3 + 3 + 4 is the same as
4 + 3 + 3.

When we first read this, it feels like a standard stars and bars
question. However, recall stars and bars also require a different
order of the addends, as previously shown. That means that this
question cannot be solved with stars and bars. Additionally,
through this problem, we’ll be able to prove the first out of three
partition formulas!
Just like other problems, we’ll look at it like a picture!
We’ll start by drawing our example in the problem 3 + 3 + 4
into a diagram.

11
Akshay A. 1 DEFINING STARS AND BARS

Remark 1.3.1 The first row of the diagram has 4, the second
row of the diagram has 3, and the last row of the diagram has
3, matching 4 + 3 + 3. This is called the Young Diagram.

To answer this question, we will make a 1 to 1


correspondence. That basically means we’ll make a change to the
scenario, while the number of ways to satisfy it stays constant.
Let’s see how that could be applied here.
We’ll draw a line through the diagram, which signals removing
the circles the line intersects.

Let’s think about what we can do with this. If we find the


number of ways three numbers x1 + x2 + x3 = 10, and if we let
x0i = xi + 1, then the number of solutions to x01 + x02 + x03 = 7, is
the same as the number of solutions to the prior equation. This is
because every solution to x01 + x02 + x03 = 7 is just a solution to
x1 + x2 + x3 = 10 if you add 1 to each of the addends.
Now, we can maybe... come up with a solution for the
problem.

Solution 1(Bogus): We can let p(n, k) = the number of


ways k positive numbers can sum to n. Due to our 1 to 1
correspondence above, we think we found p(n, k) = p(n − k, k), as
the number of rows are the same, but there are k less balls. As
we’re looking for p(10, 3), we say
p(10, 3) = p(10 − 3, 3) = p(7, 3) = p(4, 3). The only way of getting

12
Akshay A. 1 DEFINING STARS AND BARS

three positive numbers to sum to 4 is 1 + 1 + 2, so our answer is 1 .

Hmm, why is this a bogus solution? Didn’t we get the correct


1 to 1 correspondence? Well, we got a part of the 1 to 1
correspondence correct. There is another case which we did not
cover in our initial correspondence. Let’s see what that case is.

Remark 1.3.2 Whenever we derive something, always make


sure you’re covering all the cases. You don’t want to get
everything correct, but just forget 1 case!

This time, let us draw the Young Diagram with a different


configuration that sums to 10. Specifically, 6 + 3 + 1.

Now, notice that if we were to draw a line to try to do the 1


to 1 correspondence again, k would be reduced as the smallest
number is 1. This is shown in the diagram below.

Therefore, what we initially derived would not cover this case,


so we’ll need to try something else. We can do something similar
as last time, by removing a part of the diagram to account for a
specific case.

13
Akshay A. 1 DEFINING STARS AND BARS

Let us try removing that lone 1 in the bottom left corner.

Now, we have a situation where we have two numbers sum to


9. As this is the case where at least one of the numbers is 1, we can
just put a 1 as the third number. Therefore, this derivation works!

Putting it in the p(n, k) notation we used before, we get this


case is p(n − 1, k − 1) as we’re losing one group and one number.
We can put this together with our p(n − k, k), to develop our first
formula.

Theorem 1.3.1 Given p(n, k) is the number of ways k posi-


tive numbers can sum up to n, where the order doesn’t matter,
p(n, k) = p(n − k, k) + p(n − 1, k − 1).

Using this, let’s solve example 1.3.1.

Solution 2: In this problem, we want to find p(10, 3). Using


what we learned previously,
p(10, 3) = p(7, 3) + p(9, 2) = p(4, 3) + p(6, 2) + p(9, 2). p(4, 3) = 1,
as the only way is 1 + 1 + 2. p(6, 2) = 3, as the only ways are 5 + 1,
4 + 2, and 3 + 3. p(9, 2) = 4, as the only ways are 8 + 1, 7 + 2,
6 + 3, 5 + 4. Summing these values up, we get 4 + 3 + 1 = 8 .

Solution 3: Running a quick C++ program also gives us the


answer of 8 .

14
Akshay A. 1 DEFINING STARS AND BARS

Solution 2 showcases one of the many ways to use this


formula, we will get to more later! Now that we’ve completed
deriving the first formula, we can begin work on the second
formula. We can start thinking about it by making a small shift to
our original problem.

Example 1.3.2 How many ways can 3 positive distinct num-


bers sum to 10 if the order of the addends doesn’t matter? By
order of the addends doesn’t matter, it means 3 + 5 + 2 is the
same as 5 + 3 + 2.

Evidently, the change between example 1.3.2 and example


1.3.1 is that example 1.3.2 is asking for distinct numbers. We
obviously cannot do that with the formula we initially derived.
Let’s try figuring out a new formula to solve this type of a
problem. As we did with the last problem, let’s start out by
drawing the Young Diagram for 5 + 3 + 2.

Once again, we can make a 1 to 1 correspondence. If every


number is distinct and if we subtract one from each of the
numbers, then they’ll stay distinct. Therefore, we can draw a line
through the first column like we did when we were deriving the
p(n, k) formula.

15
Akshay A. 1 DEFINING STARS AND BARS

Let us say q(n, k) = the number of ways k distinct numbers


can sum to n. With what we did above, we think
q(n, k) = q(n − k, k), as there are k fewer balls. We can now start
answering the example!

WARNING: Remember, there is another case we have to


derive a formula for, don’t start jumping to conclusions right
away!

As you’re probably suspecting, we have to account for the


case where one of the numbers is 1. As expected, we will draw our
Young Diagram again, this time with 6 + 3 + 1.

Our first instinct would be to do what we did with p(n, k) and


remove that singular ball in the bottom left corner. Let’s take it
out from our diagram.

Although it seems like we can do our 1 to 1 correspondence


with this case in this manner, we are actually over counting. That

16
Akshay A. 1 DEFINING STARS AND BARS

is because in any of the two remaining rows, there can be one ball.
Then, when we add a third group of one ball, we’ll have two
groups of one ball, which means that they aren’t distinct.
Therefore, we have to think of something else to do.

WARNING: Just because a derivation worked on a specific


case, it doesn’t imply it will work in all cases.

To come up with a correspondence that actually satisfies the


case with one group having a 1, we can try to remove the entire
column just like we did with the 1st case.

This actually works! Because we are going to add 1 to each of


the first two rows, neither of them could be 1. So, we are sure
they’re distinct! Using our q(n, k) notation, this yields us
q(n − k, k − 1) as we are losing one group when we take out one
column, and we have k less balls.
We can add this to our initial q(n − k, k) to obtain our second
formula!

Theorem 1.3.2 If q(n, k) is the number of ways k distinct


positive numbers sum to n, q(n, k) = q(n − k, k) + q(n − k, k −
1).

You’ll notice both theorem 1.3.1 and theorem 1.3.2 are rather

17
Akshay A. 1 DEFINING STARS AND BARS

obscure and would be difficult to memorize. That’s why these


simple derivations help so much, as you can sometimes derive it
quickly during the test. Now, let’s write up our solution to the
example.

Solution to Example 1.3.2: We need to find q(10, 3). Using


the formula we derived earlier,
q(10, 3) = q(10 − 3, 3) + q(10 − 3, 3 − 1) = q(7, 3) + q(7, 2) =
q(4, 3) + q(4, 2) + q(7, 2). q(4, 3) is obviously 0. q(4, 2) = 1, as the
only configuration that work are 3 + 1. q(7, 2) = 3, as the
configurations that work are 6 + 1, 5 + 2, and 4 + 3. Summing
these values up, 0 + 1 + 3 = 4 .

As expected, we will be deriving our final formula using a


problem as well.

Example 1.3.3 How many ways are there for two or more
positive integers to sum to 10, such that the order matters?
(for example, 6 + 3 + 1 is different from 1 + 3 + 6).

Let us first draw 10 balls, each representing one, in a row.

I will be using two different symbols to represent different


things: + to separate the addends and ∗ to combine the balls
within an addend.
The diagram below simulates how we’re interpreting the
symbols.

18
Akshay A. 1 DEFINING STARS AND BARS

+ ∗

The simulation above shows 1 + 2, as the ∗ combines 1 and 1.

The example above perhaps gives you an idea of what we can


do to solve this problem. Between any two balls, we can either put
a + or ∗, which means there are 2 choices for every gap. As there
are 10 − 1 = 9 gaps, we have 29 possibilities. However, we cannot
combine all of them as the question asks for at least two positive
integers. Therefore, our answer is 29 − 1 = 511 . This is the
solution to example 1.3.3!

Hopefully, you will be able to generalize this to n numbers to


obtain our third and final formula.

Theorem 1.3.3 If we want to find the number of ways two


or more positive numbers sum to n, where the order matters,
the number of ways is 2n−1 − 1.

19
Akshay A. 2 PROBLEMS

2 Problems

In this chapter, we are going to do a lot of problems to help us


learn where all we can use stars and bars as well as partitions.
Problems will progressively get difficult. I have provided a hint for
some problems.

2.1 Problems

Problem 1: How many ways are there for James to give his 17
identical dimes to his 3 friends, such that each of his friends gets at
least 3 dimes? Hints: 3

Problem 2: James wants to find the number of ways three


distinct non-negative integers (including 0) can sum to 15, can you
help James?

Problem 3:(2019 AMC8 Problem 25 )Alice has 24 apples. In how


many ways can she share them with Becky and Chris so that each
of the three people has at least two apples?

Problem 4: (2018 AMC10A Problem 11 ) When 7 standard


6-sided dice are thrown, the probability that the sum of the
numbers on the top faces is 10 can be written as 6n7 , where n is a
positive integer. What is n?

Problem 5: (TMC10A Problem 18 by OTSS ) Let s(n) denote the


number of ways to partition n into two or more positive integers
such that order matters (e.g. partitioning 10 into 3 + 7 is different

20
Akshay A. 2 PROBLEMS

from 7 + 3). The value of s(1) + s(2) + ... + s(2020) can be


expressed as 2a − b where a and b are positive integers and a + b is
as small as possible. What is 10a + b?

Problem 6: (MathCounts Chapter 2020 Team 5 ) An ordered


triple (a, b, c) is randomly chosen from the set of all ordered triples
for which a, b and c are non negative integers that satisfy
a + b + c = 22. What is the probability that a < b < c? Hints: 7

Problem 7: (2016 AMC10A Problem 20 ) For some particular


value of N , when (a + b + c + d + 1)N is expanded and like terms
are combined, the resulting expression contains exactly 1001 terms
that includes all four variables a, b, c, and d, each to some positive
power. What is N ? Hints: 5

Problem 8: (2018 AMC12B Problem 22 ) Consider polynomials


P (x) of degree at most 3, each of whose coefficients is an element
of 0, 1, 2, 3, 4, 5, 6, 7, 8, 9. How many such polynomials satisfy
P (−1) = −9. Hints: 1

Problem 9: (2003 AMC10A Problem 21 ) Pat is to select six


cookies from a tray containing only chocolate chip, oatmeal, and
peanut butter cookies. There are at least six of each of these three
kinds of cookies on the tray. How many different assortments of six
cookies can be selected? Hints: 6

Problem 10: (1998 AIME Problem 7 ) Let n be the number of


ordered quadruples (x1 , x2 , x3 , x4 ) of positive odd integers that
satisfy 4i=1 xi = 98. Find 100n
P
. Hints: 4

21
Akshay A. 2 PROBLEMS

Problem 11:(1986 AIME Problem 13 ) In a sequence of coin


tosses, one can keep a record of instances in which a tail is
immediately followed by a head, a head is immediately followed by
a head, and etc. We denote these by T H, HH, and etc. For
example, in the sequence T T T HHT HT T T HHT T H of 15 coin
tosses we observe that there are two HH, four T H, and five T T
subsequences. How many different sequences of 15 coin tosses will
contain exactly two HH, three HT , four T H, and five T T
subsequences? Hints: 2

Problem 12: (2020 AMC10B Problem 25 ) Let D(n) denote the


number of ways of writing the positive integer n as a product of
n = f1 · f2 · · · fk , where k ≥ 1, the fi are integers strictly greater
than 1, and the order in which the factors are listed matters (that
is, two representations that differ only in the order of the factors
are counted as distinct). For example, the number 6 can be
written as 6, 2 · 3, and 3 · 2, so D(6) = 3. What is D(96) ? Hints: 8

2.2 Hints

1. In standard form, what does a degree 3 polynomial look like?


With that, can you make a 1 to 1 correspondence?

2. T H and HT force the last coin to be flipped. Try forcing a


sequence of them, and slotting in the other conditions later.

3. We know how to solve it if each of them has to get at least 1,


could you make a 1 to 1 correspondence to make that happen?

4. Could we add a constant number to 1, to keep the numbers


odd?

22
Akshay A. 2 PROBLEMS

5. When you open a polynomial, typically, what are the


differences between distinct terms?

6. Try rewording this problem while keeping the answer the


same.

7. Look at the numerator and denominator of the fraction we’re


looking for, we know formulas for them individually.

8. There are 6 cases, each corresponding to the number of terms


in the multiplication. Use stars and bars to put in the factors
of 2.

23
Akshay A. 2 PROBLEMS

2.3 Solutions

Here are the solutions for all 12 exercise problems. Please only
look at the solutions after you’ve attempted all the problems and
looked at the hints, because you then get more out of each
problem. I will additionally add some problem solving tips if we
used a strategy that is used in several counting problems.

Problem 1: How many ways are there for James to give his
17 identical dimes to his 3 friends, such that each of his friends
gets at least 3 dimes?

Solution: In several counting problems, one of the best


problem solving strategies is to initially take care of the restriction.
In this problem, the restriction is that each of his friends are
required to get at least 3 dimes. So how do we get rid of this? We
make a 1 to 1 correspondence. If x + y + z = 17, for x, y, and z
being integers greater than or equal to 3, then
x − 3 + y − 3 + z − 3 = 8. Let x1 = x − 3, y1 = y − 3, and
z1 = z − 3. Then, we get x1 + y1 + z1 = 8, for non negative integers
x1 , y1 , and z1 . If we calculate a solution of x1 , y1 , and z1 , then we
can just add 3 to each of x1 , y1 , and z1 to make x, y, and z. So we
have formed our 1 to 1 correspondence! We can calculate the
number of solutions for x1 , y1 , and z1 using standard stars and
bars. Using theorem1.2.2,we see  
n = 8 and k = 3. Thus, the
8+3−1 10
number of ways are 3−1 = 2 = 45 .
Another way of thinking about what we have just done is
initially giving 3 dimes to each of his friends. Then, since they’re
all happy, we have to find the number of ways to give the 8 extra
dimes to the 3 friends.

24
Akshay A. 2 PROBLEMS

Problem Solving Tip: Whenever you see a restriction


added to a counting problem, always find a way to get rid
of the restriction to make the counting easier.

Problem 2: James wants to find the number of ways three


distinct non-negative integers (including 0) can sum to 15, can
you help James?

Solution 1: When initially reading this problem, our first


instinct would be that it is just a q(n, k) problem, however, there is
one sneaky twist, “including 0”. This indicates that we also have to
account for 0, which is not in our original q(n, k) formula. So we
can split it into two cases, the first of which is just using q(n, k) to
find the number of ways three distinct positive numbers can sum
to 15. Then, we can assume one of the numbers is 0, and manually
count the number of ways two numbers can sum to 15. Let’s begin
with computing the first case. Using theorem 1.3.2, we get
q(15, 3) = q(12, 3) + q(12, 2) = q(9, 3) + q(9, 2) + q(12, 2) = q(6, 3) +
q(6, 2)+q(9, 2)+q(12, 2) = q(3, 3)+q(3, 2)+q(6, 2)+q(9, 2)+q(12, 2).
q(3, 3) is obviously 0. q(3, 2) = 1. q(6, 2) = 2. q(9, 2) = 4.
q(12, 2) = 5. Thus, q(15, 3) = 12. Now, we need to find the number
of ways two distinct positive numbers sum to 15. The ways are
1 + 14, 2 + 13, 3 + 12, 4 + 11, 5 + 10, 6 + 9, 7 + 8, which make it 7
ways. Therefore, the answer is 12 + 7 = 19 .

Solution 2: To ensure our answer is correct, we can run a c++


code. The following code simulates this and outputs 19 as well.

25
Akshay A. 2 PROBLEMS

Problem 3:(2019 AMC8 Problem 25 )Alice has 24 apples. In


how many ways can she share them with Becky and Chris so
that each of the three people has at least two apples?

Solution: This problem is similar to our first problem. As we


did in the first problem, we have to first get rid of the restriction.

26
Akshay A. 2 PROBLEMS

To do that, we’ll do a 1 to 1 correspondence. We have


x1 + x2 + x3 = 24, where xi ≥ 2. Therefore,
x1 − 2 + x2 − 2 + x3 − 2 = 18. Let xi − 2 = yi . Then,
y1 + y2 + y3 = 18 for yi ≥ 0. For every yi , there is a xi , as we just
add 2 to it. Therefore, the number of solutions of y1 + y2 + y3 = 18
is equal to the number of solutions of x1 + x2 + x3 = 24, where
xi ≥ 2. We can calculate the number of solutions to yi using stars
and bars.
 
n=18 and k = 3. Therefore the number of solutions is
18+3−1
3−1
= 202
= 190 .

Problem 4: (2018 AMC10A Problem 11 ) When 7 standard


6-sided dice are thrown, the probability that the sum of the
numbers on the top faces is 10 can be written as 6n7 , where n
is a positive integer. What is n?

Solution: As we did in the previous problems, we first want


to get rid of the restrictions in the problem. In this problem, the
restriction is each number has to be between 1 and 6, inclusive, as
the numbers have to be on a standard dice. We notice that the
denominator is the number of ways the 7 dice can be rolled, if order
matters. Therefore, we need to find the number of ways 7 dice can
sum to 10 if order matters. That indicates that we can probably
use stars and bars. We get x1 + x2 + x3 + x4 + x5 + x6 + x7 = 10,
where 1 ≤ xi ≤ 6. We know how to deal with stars and bars if each
term is at least 1, but not if we have an upper bound. So what can
we do about the upper bound condition? Let us try to see an
example of 7 positive numbers that sum to 10, where one of the
numbers is 7, which is greater than 6. The lowest we can go is
7 + 1 + 1 + 1 + 1 + 1 + 1 = 13 and 13 > 10. Therefore, it is

27
Akshay A. 2 PROBLEMS

impossible to have xi not satisfy its range. Therefore, we just


have to find the number of ways 7 numbers sum to 10, where each
number
 
is at least1. With n = 10 and k = 7, the number of ways
 
is 7−1 = 6 = 93 = 84 .
10−1 9

Problem 5: (TMC10A Problem 18 by OTSS ) Let s(n) de-


note the number of ways to partition n into two or more
positive integers such that order matters (e.g. partition-
ing 10 into 3 + 7 is different from 7 + 3). The value of
s(1) + s(2) + ... + s(2020) can be expressed as 2a − b where a
and b are positive integers and a + b is as small as possible.
What is 10a + b?

Solution: This problem is essentially an application of


theorem 1.3.3. So using theorem 1.3.3, we are able to find that
what we are looking for is 21 − 1 + 22 − 1 + 23 − 1 · · · 22019 − 1.
Grouping all the −1’s together, we get
21 + 22 + 23 + · · · + 22019 − 2019. Now we have to use the property
that ni=1 2i = 2n+1 − 2. This is a very important identity which
P

appears in math contests all the time, including this year’s 10A
problem 21. Now, applying this identity, we get
21 + 22 + 23 + · · · + 22019 − 2019 = 22020 − 2 − 2019 = 22020 − 2021.
We now have it in the correct form! We see a = 2020 and
b = 2021, therefore, the answer is 20200 + 2021 = 22221 . In this
problem, we also learned a new theorem!

Theorem 2.3.1 ni=1 2i = 2n+1 − 2. You should memorize


P

this as it comes in several contest problems.

28
Akshay A. 2 PROBLEMS

Problem 6: (MathCounts Chapter 2020 Team 5 ) An ordered


triple (a, b, c) is randomly chosen from the set of all ordered
triples for which a, b and c are non negative integers that sat-
isfy a + b + c = 22. What is the probability that a < b < c?

Solution: The official MathCounts solution involved


manually counting all the various cases. However, we can use what
we learned to be far more efficient with it. We first start with the
denominator of our fraction. It essentially is the number of ways
three non-negative
 
numbers sum to 22, using stars and bars, we
 
obtain 3−1 = 24
22+3−1
2
= 276. Now, we focus on the numerator. As
the successful outcomes occur when a < b < c, we know that a, b,
and c are all distinct. Also, we know that order doesn’t matter.
Therefore, we think we can use the q(n, k) formulas. However, we
know that one of the numbers can be 0, so we have also have to
account for that. Since we can have a 0, we need to compute
q(22, 3) + q(22, 2). Using the theorem we developed earlier,
q(22, 3) + q(22, 2) = q(19, 3) + q(19, 2) + q(22, 2) =
q(16, 3)+q(16, 2)+q(19, 2)+q(22, 2) = q(13, 3)+q(13, 2)+q(16, 2)+
q(19, 2)+q(22, 2) = q(10, 3)+q(10, 2)+q(16, 2)+q(19, 2)+q(22, 2) =
q(7, 3) + q(7, 2) + q(10, 2) + q(13, 2) + q(16, 2) + q(19, 2) + q(22, 2).
Now, we can compute each value individually. q(7, 3) = 1, as only
1 + 2 + 4 works. q(7, 2) = 3, as only 6 + 1, 5 + 2, and 4 + 3 work.
Similarly, q(13, 2) = 6, q(10, 2) = 4, q(16, 2) = 7, q(19, 2) = 9, and
q(22, 2) = 10. Summing these, we get
40 10
1 + 3 + 4 + 7 + 9 + 10 + 6 = 40. Therefore, our fraction is 276 =
69

29
Akshay A. 2 PROBLEMS

Problem 7: (2016 AMC10A Problem 20 ) For some particu-


lar value of N , when (a + b + c + d + 1)N is expanded and like
terms are combined, the resulting expression contains exactly
1001 terms that includes all four variables a, b, c, and d, each
to some positive power. What is N ?

Solution: This is a problem which requires a fair amount of


creativity and problem solving if you haven’t seen something like it
before. Let us initially start with what it means to be a distinct
term when expanding a polynomial. We can use
(a + b)2 = a2 + 2ab + b2 as an example. We cannot further combine
like terms in this expansion because each term has a different pair
of degrees. Let us have ordered pairs (a, b), where a is the degree
on the a variable and where b is the degree on the b variable. In
the expansion, we have the ordered pairs (2, 0), (1, 1), and (0, 2).
We notice that this covers every pair of two non-negative numbers
that sum to 2. We can compute the number of pairs using stars
and bars. However, this question has two caveats. First, each term
has to include all four of the variables a, b, c, and d. This implies
that every term has to have power of at least 1, we still know how
to compute that. The 2nd caveat is that the last term is 1. If we
were to have (a + b + c + d + 
e)N had 1001 terms after expanded,
we know that the answer is N4−1 = 1001, and we can just solve
the equation. If e = 1, we can think of e has having degree 0. As a
result, an extra slot opens, such that one of the terms can be 0.
Now, we’re ready to solve the problem  
fully. There are N gaps for
N
us to put 4 sticks. Therefore, we get 4 = 1001. Opening the
combination, we get N (N −1)(N4!−2)(N −3) = 1001 = 7 · 11 · 13.
Multiplying 24 on both sides, we get
N (N − 1)(N − 2)(N − 3) = 2 · 12 · 7 · 11 · 13 = 11 · 12 · 13 · 14.

30
Akshay A. 2 PROBLEMS

Comparing it to the left hand side, we can clearly see N = 11 .


These types of questions come fairly often so it’s good to
know how to solve them.

Problem 8: (2018 AMC12B Problem 22 ) Consider polyno-


mials P (x) of degree at most 3, each of whose coefficients is an
element of 0, 1, 2, 3, 4, 5, 6, 7, 8, 9. How many such polynomials
satisfy P (−1) = −9.

Solution: We start by finding out more about this polynomial.


As it’s at most a 3rd degree polynomial, we know
P (x) = ax3 + bx2 + cx + d. As P (−1) = −9, we can put x as −1
and find that −a + b − c + d = −9. Now, when looking at this
equation, there are a couple of things we don’t like about it. First,
the −a and −c are both bad, as we don’t know how to use stars
and bars to sum negative numbers. Second, the −9 is quite bad as
it is a negative number. Therefore, in an ideal situation, we would
have something in the form of a + b + c + d = 9. So now, we have
to see how we can manipulate the equation to make it like that.
We notice that if we let −a = a0 − 9 and −c = c0 − 9, then our
equation becomes a0 − 9 + b + c0 − 9 + d = −9. Simplifying, we get
a0 + b + c0 + d = 9. This is ideal as every term is between 0 and 9,
and there are no annoying negatives to deal with. Also, we have
formed a 1 to 1 correspondence since every value of a0 produces a
unique value to −a. Therefore, we can use 
stars

and
 
bars with
9+4−1 12
n = 9 and with k = 4. So our answer is 4−1 = 3 = 220 .
We would have only found the correspondence that
−a = a0 − 9 because we wanted the equation in that form. This is
a very useful technique called wishful thinking. First identify what
your ideal situation is, then manipulate whatever you have to

31
Akshay A. 2 PROBLEMS

make it your ideal situation.

Problem Solving Tip: Wishful thinking is a very powerful


strategy that can be applied to several problems. First think
what you want the problem to look like, and manipulate it to
become that.

Problem 9: (2003 AMC10A Problem 21 ) Pat is to select six


cookies from a tray containing only chocolate chip, oatmeal,
and peanut butter cookies. There are at least six of each of
these three kinds of cookies on the tray. How many different
assortments of six cookies can be selected? Hints: 6

Solution: This problem is rather simple although the


wording could confuse some people. For convenience purposes, let
the number of chocolate chip cookies be x1 , the number of oatmeal
cookies be x2 , and the number of peanut butter cookies be x3 . We
need the number of solutions such that x1 + x2 + x3 = 6. We know
that we can use stars and bars on this problem because there are
at least 6 of each of the

cookies
 
on the tray. Therefore, the number
6+3−1 8
of solutions are 3−1 = 2 = 28 .

Problem 10: (1998 AIME Problem 7 ) Let n be the number


of ordered quadruples (x1 , x2 , x3 , x4 ) of positive odd integers
that satisfy 4i=1 xi = 98. Find 100 n
P
.

Solution Just like previous problems, we ask ourselves, what is

32
Akshay A. 2 PROBLEMS

the main restriction which makes the problem hard? In this case,
the restriction is that xi has to be odd. So now, how do we get rid
of that restriction? We know we have to find the solutions of
x1 + x2 + x3 + x4 = 98, where xi is a positive odd number. We can
represent xi as 2ki + 1, for some constant k. Then, we get
2k1 + 2k2 + 2k3 + 2k4 + 4 = 98, where ki ≥ 0. Simplifying gives us
k1 + k2 + k3 + k4 = 47. As each solution of ki yields a unique
solution to xi , we just need to find the number of solutions to this
equation.
 
By
 
stars and bars, we get the number of solutions are
47+4−1 50
4−1
= 3 = 19600 = n. Therefore, the answer is
19600
100
= 196 .

Problem 11:(1986 AIME Problem 13 ) In a sequence of coin


tosses, one can keep record of instances in which a tail is im-
mediately followed by a head, a head is immediately followed
by a head, and etc. We denote these by T H, HH, and etc.
For example, in the sequence T T T HHT HT T T HHT T H of
15 coin tosses we observe that there are two HH, four T H,
and five T T subsequences. How many different sequences of
15 coin tosses will contain exactly two HH, three HT , four
T H, and five T T subsequences?

Solution: This is one of the more challenging problems


relating to stars and bars. However, if we just think logically, we
should get our answer. First, let’s analyze the different
subsequences of the coins. T H involves converting a T to an H,
and HT involves converting a H to a T . We don’t want to worry
about HH and T T yet, as we don’t convert anything within that
sub-sequence. After a bit of playing around, we notice that
T HT HT HT H has four T H subsequences and three HT

33
Akshay A. 2 PROBLEMS

subsequences. Now, we just have to add two H’s and five T ’s, as
the other H’s and T ’s to make T T and HH are already in
T HT HT HT H. Since the H’s are not distinguishable, we know
there are 4 different spaces to put the H’s. Since we have to put 2
H’s, we’ve made this a stars and bars problem. We can represent
this

ash1 + h + h3 + h4 = 2, where hi ≥ 0. There are
 2
4+2−1 5
4−1
= 3 = 10 ways to have two HH. Similarly, we have 4
gaps to put 5 T ’s in. We can represent

this

as t1 + t2 + t3 + t4 = 5,
where ti ≥ 0. Therefore, there are 4−1 = 83 = 56 ways to have
5+4−1

five T T . Therefore, the answer is 10 · 56 = 560 .

Problem 12: (2020 AMC10B Problem 25 ) Let D(n) denote


the number of ways of writing the positive integer n as a
product of n = f1 · f2 · · · fk , where k ≥ 1, the fi are integers
strictly greater than 1, and the order in which the factors are
listed matters (that is, two representations that differ only in
the order of the factors are counted as distinct). For example,
the number 6 can be written as 6, 2 · 3, and 3 · 2, so D(6) = 3.
What is D(96) ?

Solution: This is another interesting problem, which requires


some creativity (not as much as the last one though!). We first try
to find a range for k to be in. Since 96 = 25 · 3, k is at most 6.
Now, instead of using casework to calculate D(96) for various
values of k, we can try to generalize it, then sum it up at once. We
first want to take care of the singular factor of 3. The factor of 3
can be in any of the k factors. Thus, there are k ways to put in the
factor of 3. Now, the remaining k − 1 factors in our factorization,
each have to have at least one factor of 2. Therefore, we now have
5 − (k − 1) = 6 − k remaining factors of 2. There are k different

34
Akshay A. 2 PROBLEMS

factors we can put the 6 − k factors of 2 in. This is just a stars and
bars problem!
  
With

n = 6 − k and k = k, the number of ways =
6−k+k−1 5
k−1
= k−1 . Multiplying this by the number of ways we can
 
5
add the factor of 3, yields us k k−1
. Now, we just have to sum
 
P6 5
this up for all values of k from 1 to 6. k=1 k k−1
. This is equal
to 1 + 10 + 30 + 40 + 25 + 6 = 112 .

35
Akshay A. 3 ENDING REMARKS

3 Ending Remarks

3.1 Acknowledgements

In this paper, I’ve included problems from MathCounts,


OTSS, AMC10, AMC12, AIME, and some from myself.
Also, I would like to give a big thank you to Nikenissan for
spending his time to proofread the handout. If you’re looking for
someone to help you proofread a handout or co-author a handout,
you can contact him at nikenissan39@gmail.com.

3.2 Contact Information

If you still need help with problems on this topic please email
me at mathgeek145@gmail.com. Also, please go to this link to
tell me what handout you want to see next! If you would be
interested in collaborating with me, please email me.

36

You might also like