# 2013 AIME II Problems/Problem 9

## Problem 9

A $7\times 1$ board is completely covered by $m\times 1$ tiles without overlap; each tile may cover any number of consecutive squares, and each tile lies completely on the board. Each tile is either red, blue, or green. Let $N$ be the number of tilings of the $7\times 1$ board in which all three colors are used at least once. For example, a $1\times 1$ red tile followed by a $2\times 1$ green tile, a $1\times 1$ green tile, a $2\times 1$ blue tile, and a $1\times 1$ green tile is a valid tiling. Note that if the $2\times 1$ blue tile is replaced by two $1\times 1$ blue tiles, this results in a different tiling. Find the remainder when $N$ is divided by $1000$.

## Solution

Firstly, we consider how many different ways possible to divide the $7\times 1$ board. We ignore the cases of 1 or 2 pieces since we need at least one tile of each color.

• Three pieces: $5+1+1$, $4+2+1$, $4+1+2$, etc, $\dbinom{6}{2}=15$ ways in total
• Four pieces: $\dbinom{6}{3}=20$
• Five pieces: $\dbinom{6}{4}=15$
• Six pieces: $\dbinom{6}{5}=6$
• Seven pieces: $\dbinom{6}{6}=1$

Secondly, we use Principle of Inclusion-Exclusion to consider how many ways to color them:

• Three pieces: $3^3-3\times 2^3+3=6$
• Four pieces: $3^4-3\times 2^4+3=36$
• Five pieces: $3^5-3\times 2^5+3=150$
• Six pieces: $3^6-3\times 2^6+3=540$
• Seven pieces: $3^7-3\times 2^7+3=1806$

Finally, we combine them together: $15\times 6+20\times 36+15\times 150+6\times 540+1\times 1806= 8106$.

So the answer is $\boxed{106}$.

## Solution 2 (Recursive)

3 colors is a lot. How many ways can we tile an $n \mult 1$ (Error compiling LaTeX. ! Undefined control sequence.) board with one color? It's going to be $2^{n-1}$ because if you draw out the $n$ spaces, you can decide whether each of the borders between the tiles are either there or not there. There are $n-1$ borders so there are $2^{n-1}$ tilings. Define a one-tiling of an mx1 as $f_1(m)$

Now let's look at two colors. Let's see if we can get a two-tiling of an (n+1) x 1 based off a n x 1. There are 2 cases we should consider:

1) The n x 1 was a one-coloring and the block we are going to add consists of the second color. Clearly the number of ways we can do this is just $f_1(n)$

2) The n x 1 was a two-color tiling so now we've got 3 cases to form the (n+1) x 1: We can either add a block of the first color, the second color, or we can adjoin a block to the last block in the n x 1.

This gives us $f_2(n+1)=f_1(n)+3f_2(n)$

Time to tackle the 3-color tiling. Again, we split into 2 cases:

1) The n x 1 was a two-color tiling, and the block we are adding is of the 3rd color. This gives $f_2(n)$ ways but we have to multiply by 3C2 because we have to pick 2 different colors for the two-color tiling.

2) The n x 1 was a 3-color tiling, and we have to consider what we can do with the block that we are adding. It can be any of the 3 colors, or we can adjoin it to whatever was the last block in the n x 1. This gives $4f_3(n)$

So in total we have $f_3(n+1)=3f_2(n)+4f_3(n)$.

Finally, we just sorta bash through the computation to get $f_3(7)=8\boxed{106}$