高次剩余问题

二次剩余 \(\tiny\textbf{Quadratic Residue}\)

定义:令整数 \(a, p\) 满足 \(a\perp p\),且 \(p\) 为奇素数,若存在 \(x\) 使得以下式子成立:

\[x^2 \equiv a\ (\text{mod}\ p) \]

则称 \(a\) 为模 \(p\) 的二次剩余,否则 \(a\) 为模 \(p\) 的二次非剩余。

\(\text{Euler}\) 判别法

内容

\(a\) 为模 \(p\) 的二次剩余,当且仅当 \(a^{\frac{p-1}{2}} \equiv 1\ (\text{mod}\ p)\)

\(a\) 为模 \(p\) 的二次非剩余,当且仅当 \(a^{\frac{p-1}{2}}\equiv -1\ (\text{mod}\ p)\)

证明

因为 \(p\) 为奇素数,根据 \(\text{Fermat}\) 小定理有:

\[a^{p-1}\equiv 1\ (\text{mod }p) \]

\[a^{p-1}-1\equiv 0\ (\text{mod }p) \]

\[(a^{\frac{p-1}{2}}+1)(a^{\frac{p-1}{2}}-1)\equiv 0\ (\text{mod }p) \]

所以

\[a^{\frac{p-1}{2}}\equiv \pm 1\ (\text{mod }p) \]

所以只需证明若 \(a\) 为模 \(p\) 的二次剩余,当且仅当 \(a^{\frac{p-1}{2}} \equiv 1\ (\text{mod}\ p)\)

  • 充分性

因为

\[a^{\frac{p-1}{2}}\equiv 1\ (\text{mod }p) \]

\[x^2 \equiv a\ (\text{mod }p) \]

所以

\[x^{p-1}\equiv 1\ (\text{mod }p) \]

根据 \(\text{Fermat}\) 小定理,充分性得证。

  • 必要性

\(g\) 为模 \(p\) 的一个原根,那么 \(\exists\ k,\ \text{s.t.}\ g^k \equiv a\ (\text{mod }p)\)

因为

\[a^{\frac{p-1}{2}}\equiv 1\ (\text{mod }p) \]

所以

\[(g^k)^{\frac{p-1}{2}}\equiv a^{\frac{p-1}{2}}\equiv 1\ (\text{mod }p) \]

又因为 \(g\) 为模 \(p\) 的一个原根,所以 $ (p-1)|\frac{k(p-1)}{2}$,所以一定 \(\exists\ x,\ \text{s.t. }x\equiv g^{\frac{k}{2}}\ (\text{mod }p)\),此时有 \(x^2 \equiv a\ (\text{mod}\ p)\),必要性得证。


所以,若 \(a\) 为模 \(p\) 的二次剩余,当且仅当 \(a^{\frac{p-1}{2}} \equiv 1\ (\text{mod}\ p)\)

\(a\) 为模 \(p\) 的二次非剩余,当且仅当 \(a^{\frac{p-1}{2}}\equiv -1\ (\text{mod}\ p)\)

\(\text{Legendre}\) 符号

定义

对奇素数 \(p\) 与整数 \(a\)\(\text{Legendre}\) 符号定义如下:

\[\begin{pmatrix} \frac{a}{p} \end{pmatrix}= \begin{cases} 0,\ p\ |\ a \\ 1,\ (p\nmid a)\ \land\ (\exists\ x\in \mathbb{Z},\ x^2\equiv a\ (\text{mod }p)) \\ -1,\ \text{otherwise.} \end{cases} \]

性质

\[∀\ a\in \mathbb{Z},\ a^{\frac{p-1}{2}}\equiv \begin{pmatrix}\frac{a}{p}\end{pmatrix}\ (\text{mod }p) \]

\[a_1 \equiv a_2\ (\text{mod }p) \iff \begin{pmatrix}\frac{a_1}{p}\end{pmatrix}=\begin{pmatrix}\frac{a_2}{p}\end{pmatrix} \]

  1. \(\text{Legendre}\) 符号为完全积性函数:

\[\begin{pmatrix}\frac{a_1a_2}{p}\end{pmatrix}=\begin{pmatrix}\frac{a_1}{p}\end{pmatrix}\begin{pmatrix}\frac{a_2}{p}\end{pmatrix} \]

  1. 二次互反律
    \(p, q\) 为两不同奇素数,则:

\[\begin{pmatrix}\frac{p}{q}\end{pmatrix}\begin{pmatrix}\frac{q}{p}\end{pmatrix}=(-1)^{\frac{p-1}{2}\frac{q-1}{2}} \]

相关算法

特殊情况时的算法

posted @ 2024-06-19 19:11  Cuset_VoidAldehyde  阅读(48)  评论(0)    收藏  举报