1.1 模的定义与基本运算 Definition and Basic Operations
给定正整数 m,若 a 和 b 除以 m 的余数相同,则称 a 与 b 对模 m 同余,记作:
基本运算规则:
- 加法:若 a ≡ b (mod m),c ≡ d (mod m),则 a + c ≡ b + d (mod m)
- 乘法:若 a ≡ b (mod m),c ≡ d (mod m),则 ac ≡ bd (mod m)
- 幂运算:若 a ≡ b (mod m),则 ak ≡ bk (mod m),对任意正整数 k 成立
Addition, multiplication, and exponentiation all preserve congruences. These rules are the foundation of all modular computation.
In math, we always take the remainder r with 0 ≤ r < m. This convention matters in AMC problems!
1.2 同余的性质 Properties of Congruences
同余关系具有以下重要性质(等价于整数环的性质):
模的消去律(关键!):
若 ac ≡ bc (mod m) 且 gcd(c, m) = d,则 a ≡ b (mod m/d)。
Cancellation in congruences requires dividing the modulus by gcd(c, m), not by m itself. This is a very common AMC 12 trick!
You can only cancel c directly if gcd(c, m) = 1. Otherwise, divide the modulus as well!
1.3 线性同余方程 Linear Congruences
形如 ax ≡ b (mod m) 的方程称为线性同余方程。
求解方法:
- 设 d = gcd(a, m)。若 d ∤ b,则无解。
- 若 d | b,将方程两边同时除以 d:
(a/d)x ≡ (b/d) (mod m/d) - 此时 gcd(a/d, m/d) = 1,可用扩展欧几里得算法求 (a/d) 的逆元,乘以 b/d 即得解。
扩展欧几里得算法求逆元:
求 a 在模 m 下的逆元,等价于求整数 x, y 使得 ax + my = gcd(a, m) = 1,此时 x 即为逆元。
2.1 Fermat小定理 Fermat's Little Theorem (FLT)
等价形式:对任意整数 a,ap ≡ a (mod p)(包括 a ≡ 0 mod p 的情况)。
An equivalent form: a^p ≡ a (mod p) for all integers a (this version includes the case a ≡ 0 mod p).
典型应用:求大数的模 p 余数、质数判定、证明某些数不是质数。
例:求 72025 mod 13。
解:13 是质数,7 ∤ 13。由 FLT:712 ≡ 1 (mod 13)。
2025 = 12 × 168 + 9,所以 72025 = (712)168 × 79 ≡ 1168 × 79 ≡ 79 (mod 13)。
继续化简:72 ≡ 49 ≡ 10 (mod 13),74 ≡ 102 ≡ 9 (mod 13),78 ≡ 92 ≡ 81 ≡ 3 (mod 13),所以 79 ≡ 78 × 7 ≡ 3 × 7 = 21 ≡ 8 (mod 13)。
2.2 Euler定理 Euler's Theorem
其中 φ(n) 是 Euler φ 函数,表示 1 到 n 中与 n 互质的整数个数。
φ(n) 的计算公式:
- 若 n = pk(p 为质数),φ(n) = pk − pk−1 = pk(1 − 1/p)
- 若 n = p·q(p, q 为不同质数),φ(n) = (p−1)(q−1)
- 若 n = p1a1 · p2a2 · ...,则 φ(n) = n · ∏(1 − 1/pi)
Euler's Theorem is a generalization of FLT. When n = p (prime), φ(p) = p − 1, so Euler's Theorem becomes FLT.
2.3 中国剩余定理 Chinese Remainder Theorem (CRT)
求解方法(构造法):
设 M = m1m2⋯mk,Mi = M/mi,求 Mi 在模 mi 下的逆元 ti(即 Miti ≡ 1 (mod mi))。
则通解为:
简化版(两个方程时):
解 x ≡ a (mod m),x ≡ b (mod n)(其中 m, n 互质):
x = a + m·[(b − a) · m−1 mod n],取最小非负解即得。
2.4 Wilson定理 Wilson's Theorem
这是质数判定的充要条件(比 FLT 的逆命题更强)。
重要推论:
- 若 (p − 1)! ≡ −1 (mod p),则 p 一定是质数(但这计算量太大,不适合做大数判定)。
- 在模 p 下,1, 2, …, p−1 的乘法逆元是配对的:i · (p−i) ≡ −1 (mod p)。
Wilson定理的推论:对于质数 p > 2,(p−1)! ≡ 1 · 2 · ... · (p−1) ≡ −1 (mod p),且在配对 (1, p−1), (2, p−2), ... 时,每对的乘积 ≡ −1 (mod p)。
3.1 阶(Order)的概念 Order of an Integer
基本性质:
- ordn(a) 总是 φ(n) 的约数(由 Euler 定理:aφ(n) ≡ 1 mod n)
- 若 at ≡ 1 (mod n),则 ordn(a) | t
- 若 ordn(a) = d,则 a1, a2, …, ad 在模 n 下两两不同
The order always divides φ(n). This is a powerful tool for solving problems about cycles and periodicity in modular arithmetic.
3.2 原根 Primitive Roots
原根的意义:从 g0, g1, …, gφ(n)−1 可以生成模 n 下所有与 n 互质的数。
原根的存在性:
| 模 n | 是否有原根 | Has Primitive Root? |
|---|---|---|
| 2, 4, pk, 2pk(p 为奇质数) | 是 | Yes |
| 其他 n | 否 | No |
重要性质:
- 若 g 是模 p 的原根(p 为质数),则 {g1, g2, …, gp−1} 恰好构成模 p 乘法群的全部非零元素
- 模 p 的原根个数为 φ(p−1)
3.3 Legendre符号简介 Legendre Symbol
核心性质:
- 乘法性:(ab/p) = (a/p)(b/p)
- Euler判别法:(a/p) ≡ a(p−1)/2 (mod p)
- 二次互反律(Quadratic Reciprocity):若 p, q 为奇质数,则 (p/q)·(q/p) = (−1)((p−1)/2)·((q−1)/2)
Legendre's symbol tells us whether a is a quadratic residue (a perfect square) modulo a prime p. The law of quadratic reciprocity relates (p/q) and (q/p).
3.4 Diophantine方程 Diophantine Equations
Diophantine 方程是指未知数只能取整数值的方程。AMC 12 中常见的类型包括:
① 线性Diophantine方程:ax + by = c
② Pell方程:x² − ny² = 1(n为非完全平方数)
Pell 方程总是有无穷多组正整数解。其最小解 (x₁, y₁) 可以通过连分数展开求得。
Pell's equation has infinitely many solutions, and all solutions can be generated from the minimal solution via recurrence relations.
③ 指数型Diophantine(如 ax − by = c)
这类方程通常利用模运算来限制可能的解,再用枚举或因式分解求解。
求 2100 mod 13 的值。 Find 2100 mod 13.
100 = 12 × 8 + 4,所以 2100 = (212)8 × 24 ≡ 18 × 16 ≡ 16 ≡ 3 (mod 13)。
By FLT: 212 ≡ 1 (mod 13). 100 = 12×8+4, so 2100 ≡ 24 ≡ 16 ≡ 3 (mod 13).
求满足 5x ≡ 3 (mod 12) 的最小正整数 x。 Find the smallest positive integer x satisfying 5x ≡ 3 (mod 12).
求逆元:5 × ? ≡ 1 (mod 12),5 × 5 = 25 ≡ 1 (mod 12),所以 5−1 ≡ 5。
两边乘以 5−1:x ≡ 3 × 5 ≡ 15 ≡ 3 (mod 12)。
gcd(5,12)=1. Find 5−1 ≡ 5 (mod 12). Then x ≡ 3×5 ≡ 15 ≡ 3 (mod 12).
求同余方程组 x ≡ 2 (mod 3),x ≡ 3 (mod 5),x ≡ 2 (mod 7) 的最小正整数解。 Find the smallest positive solution of the system: x ≡ 2 (mod 3), x ≡ 3 (mod 5), x ≡ 2 (mod 7).
M1 = 35,逆元 35−1 ≡ 35−1 ≡ 2 (mod 3)(因为 35 ≡ 2,2×2=4≡1)
M2 = 21,逆元 21−1 ≡ 21−1 ≡ 1 (mod 5)(21≡1)
M3 = 15,逆元 15−1 ≡ 1 (mod 7)(15≡1)
x ≡ 2×35×2 + 3×21×1 + 2×15×1 = 140 + 63 + 30 = 233 ≡ 233−210 = 23 (mod 105)。
M = 105. x = 2×35×2 + 3×21×1 + 2×15×1 = 233 ≡ 23 (mod 105). Smallest positive solution is 23.
求 φ(72) 的值。 Find φ(72).
φ(72) = 72 × (1 − 1/2) × (1 − 1/3) = 72 × 1/2 × 2/3 = 72 × 1/3 = 24。
72 = 2³ × 3². φ(72) = 72 × (1−½)(1−⅓) = 72 × ½ × ⅔ = 24.
方程 6x + 15y = 21 是否有整数解?若有,求出一组正整数解。 Does 6x + 15y = 21 have integer solutions? If yes, find one with positive integers.
找特解:6×(−4) + 15×3 = −24 + 45 = 21,所以 (x₀, y₀) = (−4, 3)。
通解:x = −4 + (15/3)·t = −4 + 5t,y = 3 − (6/3)·t = 3 − 2t,t ∈ ℤ。
若要求正整数,取 t=1 得 x=1, y=1(也是正整数解)。
gcd(6,15)=3|21, so solutions exist. Try x=−4, y=3: 6(−4)+15(3)=−24+45=21. General: x=−4+5t, y=3−2t. With t=1: x=1, y=1.
第1题 32024 mod 7 的值是多少? What is 32024 mod 7?
第2题 同余方程 4x ≡ 6 (mod 10) 有多少个模10下互不相同的解? How many distinct solutions modulo 10 does 4x ≡ 6 (mod 10) have?
第3题 求 φ(60) 的值。 Find φ(60).
第4题 用中国剩余定理求 x ≡ 1 (mod 4),x ≡ 2 (mod 3) 的最小正整数解。 Using CRT, find the smallest positive solution of x ≡ 1 (mod 4), x ≡ 2 (mod 3).
第5题 Wilson定理:若 p 是质数,(p−1)! mod p 的值是? By Wilson's theorem, if p is prime, what is (p−1)! mod p?
第6题 求满足 7x ≡ 5 (mod 12) 的最小正整数 x。 Find the smallest positive x satisfying 7x ≡ 5 (mod 12).