A number is called trilegal if its digits belong to the set \(\{1, 2, 3\}\) and if it is divisible by \(99\). How many trilegal numbers with \(10\) digits are there?
Problem
Source: Brazilian Mathematical Olympiad 2024, Level 2, Problem 4
Tags: number theory, combinatorics, counting
13.10.2024 00:48
Let $N=\overline{a_{10}a_9a_8a_7a_6a_5a_4a_3a_2a_1}$ be a trilegal number with $10$ digits. Define $A=a_{10}+a_8+a_6+a_4+a_2$ and $B=a_9+a_7+a_5+a_3+a_1$. Since $N$ is divisible by $99$, we must have $9|N$ and $11|N$. But, by their respective divisibility criteria this will occur if and only if $9|A+B$ and $11|A-B$. However, notice that $15\geq A \geq5$ and $15\geq B \geq5$, then $10\geq A-B\geq-10$, so $A-B=0\Rightarrow A=B$. Therefore $9|2A\Rightarrow 9|A$, but $15\geq A \geq5$, then we must have $A=9$. Now, notice that for each solution $(a_{10},a_8,a_6,a_4,a_2)$ of equation $A=9$, we can combine it with another solution $(b_{10},b_8,b_6,b_4,b_2)$ in order to form a trilegal number. So, the number of trilegal numbers with $10$ digits is exactly equal to the square of the number of distinct solutions to the equation $A=9$. So, let's calculate this value, dividing it into three cases: None of the digits is equal to $3$: Note that we cannot have more than two digits being equal to $1$, since then we will have $A\leq8$, but we also cannot have all digits equal to $2$, since we would have $A=5\times2=10$, therefore, the only solution is when we have one digit equal to $1$ and the others equal to $2$, totaling $5$ distinct solutions. One of the digits is equal to $3$: Suppose WLOG is $a_{10}$. Then we want to calculate the number of solutions for $a_8+a_6+a_4+a_2=6$. Clearly, we must have at least two digits equal to $1$, giving us that the sum of the other two must be $4$, but since we cannot have any other three, they must equal $2$. Therefore, the number of solutions for this case is the number of distinct permutations of $(5,1,1,2,2)$ which we know to be $5\times\frac{4!}{2!\times2!}=30$ Two of the digits is equal to $3$:Suppose, WLOG, that $a_{10}$ and $a_8$ are. Then, we want to calculate the number of solutions for $a_6+a_4+a_2=3$, but it is easy to see that we cannot have digits other than $1$, since the others should be less than or equal to $0$, which cannot occur, so the only solutions are the permutations of $(5,5,1,1,1)$ that we know totals $\frac{5!}{2!\times3!}=10$ Thus, by the additive principle, for $A=9$, there are $5+30+10=45$ solutions, so, there are $45^2=2025$ $10$-digits trilegal numbers
13.10.2024 23:26
There's actually another way to count the number of trilegal numbers that i think it's interesting to share which is $[\binom{8}{4}-(\binom{5}{3}+\binom{5}{4})]^2$ As stated in the comment above $A=B=9$ and we just need to find the number of solution of $A=9$ and square it. Lemma:: The number of solutions of the equation $\sum_{i=1}^{m}x_i=n$ where $x_1, x_2...x_m$ and $n$ are positive integers is $\binom{n-1}{m-1}$. Proof:: Let's take a small example, $x_1+x_2+x_3=5$ and now imagine we have $5$ balls and $2$ sticks, with $2$ sticks we can divide the balls in $3$ different regions $x_1, x_2, x_3$. One way to do that is like this O/OOO/O, but notice that this corresponds to the triple $(1,3,1)$ so the number of solutions of the equation is actually $\binom{4}{2}$ where $4=$the number of spaces between the balls that we can put the sticks( the number in question $-1$) and $2=$the number of sticks( the number of variables $-1$). Generalizing, with $n$ balls we have $n-1$ spaces and $m-1$ sticks therefore the answer of the number of solutions of the equation $\sum_{i=1}^{m}x_i=n$ is $\binom{n-1}{m-1}$. I hope that's clear. So now going back to the original problem $A=\sum_{i=1}^{5}a_{2i}=9$ the number of solutions will be $\binom{9-1}{5-1}=70$ but we have some restrictions here , all the $a_i$ with $1\le i \le10$ must be $1,2$ or $3$ so we must remove what we do not want which is actually pretty simple in this problem. Obviously if $a_i\ge6$ we have no solutions and let's also suppose $a_i>3$ with this we have the inequality $4\le a_i \le 5$ Case $a_i=4$ The only posible set of number that satisfy the equation $A=\sum_{i=1}^{5}a_{2i}=9$ is $(4,2,1,1,1)$ and here we see that the number of solutions will be $\binom{5}{3}$. Case $a_i=5$ The only set of numbers that can satisfy $A=\sum_{i=1}^{5}a_{2i}=9$ is $(5,1,1,1,1)$ and here we have a total of $\binom{5}{4}$ solutions. So finally the answer to our problem is the total of solution minus what we do not want, in this case $[\binom{8}{4}-(\binom{5}{3}+\binom{5}{4})]^2=45^2=2025$.