Maths Olympiad Prep

Library / /233 of 520

Number theory Difficulty 6.8 National olympiad Find the answer

For any positive integer, if the number of 22's in its digits is greater than the number of 33's in its digits, we call that is a good number. And if the number of 33's in its digits is more than the number of 22's in its digits, we call that is a bad number. For example, there are two 22's and one 33 in the number 20232023, so 20232023 is a good number. But in the number 123123, the number of 22 and 33 are both one, so 123123 is neither a good number nor a bad number.

Find the difference of numbers of good numbers and bad numbers among the positive integer not greater than 20232023.

A number or a short expression. Fractions can be typed as 3/2, and spacing doesn't matter.

Solution

1. Define the sets and functions:
- Let G(m,n)={xNmxn;  x is a good number} G(m,n) = \{ x \in \mathbb{N} \mid m \le x \le n; \; x \text{ is a good number} \}
- Let g(m,n)=G(m,n) g(m,n) = |G(m,n)|
- Let B(m,n)={yNmyn;  y is a bad number} B(m,n) = \{ y \in \mathbb{N} \mid m \le y \le n; \; y \text{ is a bad number} \}
- Let b(m,n)=B(m,n) b(m,n) = |B(m,n)|
- We need to find d=g(1,2023)b(1,2023) d = g(1,2023) - b(1,2023)

2. Break down the range:
- g(1,2023)=g(1,1999)+g(2000,2023) g(1,2023) = g(1,1999) + g(2000,2023)
- b(1,2023)=b(1,1999)+b(2000,2023) b(1,2023) = b(1,1999) + b(2000,2023)

3. **Prove g(1,1999)=b(1,1999) g(1,1999) = b(1,1999) :**
- Let U={1,2,,1998,1999} U = \{1, 2, \dots, 1998, 1999\}
- For uU u \in U , represent u u as u=u3103+u2102+u110+u0 u = u_3 \cdot 10^3 + u_2 \cdot 10^2 + u_1 \cdot 10 + u_0 where u3{0,1} u_3 \in \{0,1\} and u2,u1,u0{0,1,,9} u_2, u_1, u_0 \in \{0,1,\dots,9\}
- Define the function T:UU T: U \to U such that:
vk={ukif uk{0,1,4,5,6,7,8,9}3if uk=22if uk=3 v_k = \begin{cases} u_k & \text{if } u_k \in \{0,1,4,5,6,7,8,9\} \\ 3 & \text{if } u_k = 2 \\ 2 & \text{if } u_k = 3 \end{cases}
for k{0,1,2,3} k \in \{0,1,2,3\}

4. **Properties of T T :**
- T(T(u))=u T(T(u)) = u for all uU u \in U , hence T T is injective.
- If uG(1,1999) u \in G(1,1999) , then T(u)B(1,1999) T(u) \in B(1,1999) , implying g(1,1999)b(1,1999) g(1,1999) \le b(1,1999)
- If uB(1,1999) u \in B(1,1999) , then T(u)G(1,1999) T(u) \in G(1,1999) , implying b(1,1999)g(1,1999) b(1,1999) \le g(1,1999)

5. Conclusion from properties:
- From the above properties, we get g(1,1999)=b(1,1999) g(1,1999) = b(1,1999)

6. **Calculate g(2000,2023) g(2000,2023) and b(2000,2023) b(2000,2023) :**
- The set V=[2000,2023]N V = [2000,2023] \cap \mathbb{N} contains 24 elements.
- Numbers 2003 and 2013 are neither good nor bad.
- Therefore, V{2003,2013}G(2000,2023) V \setminus \{2003,2013\} \subset G(2000,2023)
- Hence, g(2000,2023)=22 g(2000,2023) = 22 and b(2000,2023)=0 b(2000,2023) = 0

7. Final calculation:
- d=g(2000,2023)b(2000,2023)=220=22 d = g(2000,2023) - b(2000,2023) = 22 - 0 = 22

The final answer is 22 \boxed{22}

Want a route through all this instead of an archive? The track puts 2,000 problems in a working order, from AMC 10 level to the IMO shortlist.

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