Olympiad Maths Prep

Track / Stage 5 / 110 of 400 #710 of 2000

Problem 710

AIME late
Combinatorics Difficulty 5.3 Find the answer

5. Form an nn-digit number using the digits 1,2,31, 2, 3, requiring that each of 1,2,31, 2, 3 appears at least once in the nn-digit number. The total number of such nn-digit numbers is \qquad .

Official solution

5. 3n32n+33^{n}-3 \cdot 2^{n}+3.

Let the set of all nn-digit numbers composed of the digits 1,2,31, 2, 3 be denoted as II, and the sets of all nn-digit numbers in II that do not contain the digits 1,2,31, 2, 3 be denoted as A1,A2,A3A_{1}, A_{2}, A_{3}, respectively. Then I=3n,A1=A2=A3=2n,AiAj=1|I|=3^{n},\left|A_{1}\right|=\left|A_{2}\right|=\left|A_{3}\right|=2^{n},\left|A_{i} \cap A_{j}\right|=1, (1i<j3),A1A2A3=0(1 \leqslant i<j \leqslant 3),\left|A_{1} \cap A_{2} \cap A_{3}\right|=0, thus A1A2A3=IA1A2A3+\left|\overline{A_{1} \cup A_{2} \cup A_{3}}\right|=|I|-\left|A_{1}\right|-\left|A_{2}\right|-\left|A_{3}\right|+ A1A2+A2A3+A3A1A1A2A3=3n32n+3×10=3n\left|A_{1} \cap A_{2}\right|+\left|A_{2} \cap A_{3}\right|+\left|A_{3} \cap A_{1}\right|-\left|A_{1} \cap A_{2} \cap A_{3}\right|=3^{n}-3 \cdot 2^{n}+3 \times 1-0=3^{n}- 32n+33 \cdot 2^{n}+3.

Source: NuminaMath-1.5, licensed Apache-2.0. Statement and solution reproduced as published; topic, difficulty and ordering added by this site.