2012 AIME II Problem 12

Attempt Problem 12 of the 2012 AIME II below, then check your answer against the professionally curated solution from LIVE by Po-Shen Loh. You can also try the full timed exam, view all 2012 AIME II solutions, or check the answer key.

All problems are used with official legal permission of the Mathematical Association of America (MAA).

12.

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.
Answer: 958
Concepts:modular arithmeticChinese Remainder Theorem
Small hint:
nn is pp-safe exactly when 3≤n mod p≤p−33 \le n \bmod p \le p - 3
Big hint:
Since 7⋅11⋅13=1001,7 \cdot 11 \cdot 13 = 1001, count the safe residues in each block of 10011001 consecutive integers, then adjust near the cutoff 10,00010{,}000
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.
LIVE by Po-Shen Loh
Programs

LIVE Classes

Self-Paced Classes

Stars

Scholarship

About Us

Who Is Po-Shen Loh?

Email Contact

Newsletter

Jobs

Become a Star

For a more Thought Full world.

© 2026 Expii, Inc.