一次同余式

一次同余式有解

axb(modm)a\cdot x\equiv b\left(\mod m\right)有解(a,m)b\Longleftrightarrow\left(a,m\right)\mid b xb(a,m)((a(a,m))1(modm(a,m)))+tm(a,m)(modm)x\equiv \frac{b}{\left(a,m\right)}\cdot\left({\left(\frac{a}{\left(a,m\right)}\right)}^{-1}\left(\mod \frac{m}{\left(a,m\right)}\right)\right)+t\cdot\frac{m}{\left(a,m\right)}\left(\mod m\right) t=0,1,,(a,m)1t=0,1,\cdots,\left(a,m\right)-1

一次同余式求解

  • STEP1: 验证有解

  • STEP2: 求解a(a,m)x1(modm(a,m))\frac{a}{\left(a,m\right)}\cdot x\equiv 1\left(\mod \frac{m}{\left(a,m\right)}\right)

    广义欧几里得除法得到特解x0c(modm(a,m))x_{0}^{\prime}\equiv c\left(\mod \frac{m}{\left(a,m\right)}\right)

  • STEP3: 求同余式a(a,m)xb(a,m)(modm(a,m))\frac{a}{\left(a,m\right)}\cdot x\equiv \frac{b}{\left(a,m\right)}\left(\mod \frac{m}{\left(a,m\right)}\right)

    得到特解x0b(a,m)x0b(a,m)cd(modm(a,m))x_0\equiv \frac{b}{\left(a,m\right)}\cdot x_{0}^{\prime}\equiv \frac{b}{\left(a,m\right)}\cdot c\equiv d\left(\mod \frac{m}{\left(a,m\right)}\right)

  • STEP4: 写出全部解

    xd+tm(a,m)(modm),t=0,1,,(a,m)1x\equiv d+t\cdot\frac{m}{\left(a,m\right)}\left(\mod m\right),t=0,1,\cdots,\left(a,m\right)-1

最后更新于