2026-08-05

Problem — 2026-08-05

Medium

MediumNumber theory

A secret spy organization uses a peculiar encryption system. Each agent has a secret ID number between 1 and 999. To authenticate, an agent must announce a number NN such that when you compute N2 mod 1000N^2 \bmod 1000, you get their ID number. The spy agency discovered that some ID numbers are "secure" (exactly one valid NN exists between 1 and 1000) while others are "compromised" (multiple valid values of NN exist). For example, ID 376 is secure because only N=624N = 624 works, but ID 0 is compromised because N∈{0,250,500,750,1000}N \in \{0, 250, 500, 750, 1000\} all work. How many ID numbers between 1 and 999 are secure?

Enter a whole number

Show solution
We need to find how many values d∈{1,2,…,999}d \in \{1, 2, \ldots, 999\} have exactly one solution to x2≡d(mod1000)x^2 \equiv d \pmod{1000} in the range x∈{1,2,…,1000}x \in \{1, 2, \ldots, 1000\}. First, note that 1000=8×125=23×531000 = 8 \times 125 = 2^3 \times 5^3. By the Chinese Remainder Theorem, x2≡d(mod1000)x^2 \equiv d \pmod{1000} if and only if both: - x2≡d(mod8)x^2 \equiv d \pmod{8} - x2≡d(mod125)x^2 \equiv d \pmod{125} For any dd with gcd⁡(d,1000)=1\gcd(d, 1000) = 1 (i.e., dd coprime to 1000), the number of solutions modulo 1000 equals the product of solutions modulo 8 and modulo 125. The quadratic residues modulo 8 are {0,1,4}\{0, 1, 4\}: - d≡0(mod8)d \equiv 0 \pmod{8}: 4 solutions modulo 8 - d≡1(mod8)d \equiv 1 \pmod{8}: 2 solutions modulo 8 - d≡4(mod8)d \equiv 4 \pmod{8}: 2 solutions modulo 8 The quadratic residues modulo 125: For odd primes pp, a non-zero dd coprime to pp has either 0 or 2 square roots modulo pp. For d≡0(modp)d \equiv 0 \pmod{p}, the structure is more complex. Key insight: If dd is coprime to 1000, then modulo 8 it's either 1, 3, 5, or 7. Only d≡1(mod8)d \equiv 1 \pmod{8} is a quadratic residue, giving 2 solutions mod 8. Similarly, if dd is a quadratic residue mod 125, it has 2 solutions mod 125. By CRT, this gives 2×2=42 \times 2 = 4 solutions modulo 1000. If dd is NOT coprime to 1000, the analysis becomes more intricate, but in all cases, the number of solutions is either 0 or ≥2\geq 2. The critical observation: For x2≡d(mod1000)x^2 \equiv d \pmod{1000}, if xx is a solution, so is 1000−x1000 - x (when working in residues 1 to 1000). These are distinct unless x=1000−xx = 1000 - x, which means x=500x = 500. But 5002=250000≡0(mod1000)500^2 = 250000 \equiv 0 \pmod{1000}. For any d≠0d \neq 0: if xx is a solution with 1≤x≤10001 \leq x \leq 1000 and x2≡d(mod1000)x^2 \equiv d \pmod{1000}, then 1000−x1000 - x is also a solution (and 1000−x≠x1000-x \neq x for x≠500x \neq 500). Thus every non-zero dd has either 0 solutions or at least 2 solutions in {1,…,1000}\{1, \ldots, 1000\}. Therefore, **no ID numbers between 1 and 999 are secure**. The answer is 0\boxed{0}.