Skip to main content

2024 AIME II Problem 7

Problem 7 of 15IntermediateNumber TheoryProblem-Solving Techniques

Let NN be the greatest four-digit integer with the property that whenever one of its digits is changed to 1,1, the resulting number is divisible by 7.7. Let QQ and RR be the quotient and remainder, respectively, when NN is divided by 1000.1000. Find Q+R.Q + R.

Your answer

Integer from 0 to 999
Show solution

Solution

Write NN with digits a,b,c,d.a, b, c, d. Changing the thousands digit to 11 produces N−(a−1)⋅1000,N - (a - 1) \cdot 1000, so N≡1000(a−1)(mod7),N \equiv 1000(a-1) \pmod 7, and similarly for the other digits. Since 1000≡6,1000 \equiv 6, 100≡2,100 \equiv 2, and 10≡3(mod7),10 \equiv 3 \pmod 7, N≡6(a−1)≡2(b−1)≡3(c−1)≡d−1(mod7). \begin{aligned} N &\equiv 6(a-1) \\ &\equiv 2(b-1) \equiv 3(c-1) \\ &\equiv d - 1 \pmod 7. \end{aligned} Let k=N mod 7.k = N \bmod 7. Using 6≡−16 \equiv -1 and the inverses 2−1≡4,2^{-1} \equiv 4, 3−1≡5,3^{-1} \equiv 5, the digits satisfy a≡1−k,a \equiv 1 - k, b≡1+4k,b \equiv 1 + 4k, c≡1+5k,c \equiv 1 + 5k, d≡1+k(mod7).d \equiv 1 + k \pmod 7. But also k≡Nk \equiv N ≡6a+2b+3c+d(mod7);\equiv 6a + 2b + 3c + d \pmod 7; substituting gives k≡12+18k≡5+4k,k \equiv 12 + 18k \equiv 5 + 4k, so 3k≡23k \equiv 2 and k≡3(mod7).k \equiv 3 \pmod 7. Then a≡5,a \equiv 5, b≡6,b \equiv 6, c≡2,c \equiv 2, d≡4(mod7),d \equiv 4 \pmod 7, and taking the largest digit in each class gives a=5a = 5 (the class {5,12,…}\{5, 12, \ldots\} has no larger digit), b=6,b = 6, c=9,c = 9, d=4:d = 4: N=5694.N = 5694. Indeed 1694,5194,5614,56911694, 5194, 5614, 5691 are all multiples of 7.7. Finally Q=5,Q = 5, R=694,R = 694, and Q+R=699.Q + R = 699.
AoPS wiki

Tagged: modular arithmetic · digits · optimization

More practice