Joãozinho wrote a multiplication on the board and, right after, Pedrinho replaced the digits with symbols and letters as shown below:

$$
\begin{array}{r}
\star \star \star \star \star \star \star A \\
\times \quad A \\
\hline B B B B B B B B B
\end{array}
$$

The letter $A$ represents the same digit, that is, where it now appears, the same digit was there before. The same applies to the letter $B$. On the other hand, the stars $\star$ can represent different digits from each other. What was the multiplication that Joãozinho wrote?
Solution

First, we notice that if we know $A$, then $B$ is the units digit of the number $A \times A$. And knowing $B$, we can perform the inverse operation, dividing the number $B B B B B B B B B$ by $A$ and see if we get a number of the form $\star \star \star \star$ $\star \star \star A$. Here it is worth noting that the number $B B B B B B B B B$ has 9 digits, while $\star \star \star \star \star \star \star \star A$ only has 8.

So let's get started:

If $A=1$, then $B=1$, and it is easy to see that dividing 111111111 by 1 gives a number with 9 digits, not 8 digits. The same happens in the cases $A=2$ and $A=3$. If $A=2$, then $B=4$ and

$$
444444444 \div 2=222222222
$$

which cannot happen because 222222222 has 9 digits. If $A=3$, then $B=9$ and

$$
999999999 \div 3=333333333
$$

which also has 9 digits.

If $A=4$, then $B=6$. In this case, dividing 666666666 by 4 is not exact. In fact, the division has a quotient of 166666666 and a remainder of 2. Therefore, $A$ cannot be 4.

If $A=5$, then $B=5$ as well, and therefore

$$
555555555 \div 5=111111111
$$

which has 9 digits and does not end in 5.

If $A=6$, then $B=6$ as well, and therefore

$$
666666666 \div 6=111111111
$$

which has 9 digits and does not end in 6.

If $A=7$, then $B=9$. As in the case of $A=4$, we see that dividing 999999999 by 7 is not exact. In fact, the division has a quotient of 142857142 and a remainder of 5.

If $A=8$, then $B=4$. As before, dividing 444444444 by 8 is not exact, with a quotient of 55555555 and a remainder of 4.

Finally, if $A=9$, then $B=1$. And dividing

$$
111111111 \div 9=12345679
$$

which is an 8-digit number ending in 9. Therefore, the multiplication that Joãozinho wrote on the board was

12345679

| $\times \quad 9$ |
| ---: |
| 111111111 |