设α\alphaα为答案的周期,则有m×α≡n×α(modL)m \times \alpha \equiv n \times \alpha \pmod Lm×α≡n×α(modL) ,化简得(m−n)×α≡0(modL)(m-n) \times \alpha \equiv0 \pmod L(m−n)×α≡0(modL) 此时αmin=lcm(L,m−n)m−n\alpha_{\min}=\frac{\mathrm{lcm(L,m - n)} }{m - n}αmin=m−nlcm(L,m−n)所以只用模lcm(L,m−n)m−n\frac{\mathrm{lcm(L,m - n)} }{m - n}m−nlcm(L,m−n)即可
Pre Now