中国剩余定理

中国剩余定理(chinese remainder theorem)

若整数(m_1,m_2,cdots,m_n)两两互质,且(M=m_1m_2cdots m_n),那么对于任意整数(a_1,a_2,cdots,a_n),关于(x)的同余方程组

[egin{cases} xequiv a_1\,mod\,m_1\ xequiv a_2\,mod\,m_2\ vdots\ xequiv a_n\,mod\,m_n\ end{cases} ]

有模(M)的唯一解:
(M_i=M/m_i)(M_i^{-1})为其模(m_i)的逆元,即(M_i^{-1}M_iequiv 1\,mod\,m_i),那么同余方程组的通解为:

[xequiv left(sum_{i=1}^{n}{a_iM_i^{-1}M_i} ight)\,mod\,M ]

原文地址:https://www.cnblogs.com/HachikoT/p/13910466.html