Skip to main content

2012 AIME II Problem 12

Problem 12 of 15HarderNumber Theory

For a positive integer p,p, define the positive integer nn to be pp-safe if nn differs in absolute value by more than 22 from all multiples of p.p. For example, the set of 1010-safe numbers is {3,\{3, 4,4, 5,5, 6,6, 7,7, 13,13, 14,14, 15,15, 16,16, 17,17, 23,23, …}.\ldots\}. Find the number of positive integers less than or equal to 10,00010{,}000 which are simultaneously 77-safe, 1111-safe, and 1313-safe.

Your answer

Integer from 0 to 999
Show solution

Solution

Being pp-safe depends only on n mod p:n \bmod p: it requires 3≤n mod p≤p−3.3 \le n \bmod p \le p - 3. That allows 22 residues modulo 7,7, 66 residues modulo 11,11, and 88 residues modulo 13.13. Since 7⋅11⋅13=1001,7 \cdot 11 \cdot 13 = 1001, the Chinese remainder theorem gives exactly 2⋅6⋅8=962 \cdot 6 \cdot 8 = 96 safe residues modulo 1001,1001, so each block of 10011001 consecutive integers contains 9696 safe numbers. The integers 11 through 1001010010 form ten such blocks, containing 960960 safe numbers. It remains to discard the safe numbers among 10001,…,10010.10001, \ldots, 10010. Their residues modulo 77 run 5,6,0,1,2,3,4,5,6,0,5, 6, 0, 1, 2, 3, 4, 5, 6, 0, so only 1000610006 and 1000710007 are 77-safe; both are also 1111-safe (residues 77 and 88) and 1313-safe (residues 99 and 1010). Therefore the count is 960−2=958.960 - 2 = 958.
AoPS wiki

Tagged: modular arithmetic · Chinese Remainder Theorem

More practice