Linear Congruence Equation(s)

Linear Congruence Equation:

Linear Congruence Equation(s)_第1张图片

Chinese Remainder Theore

Linear Congruence Equation(s)_第2张图片

Linear Congruence Equation(s)_第3张图片

Linear Congruence Equations:

Linear Congruence Equation(s)_第4张图片
namespace math
{
    ll lce(ll r[],ll m[],int n)
    {
        for(int i=2;i<=n;i++)
        {
            eg t=exgcd(m[1],m[i]);
            if((r[i]-r[1])%t.r)return -1;
            ll md=m[i]/t.r;
            t.x=((r[i]-r[1])/t.r*t.x%md+md)%md;
            r[1]+=m[1]*t.x,m[1]=m[1]/t.r*m[i];
        }
        return r[1];
    }
}
using math::lce;

你可能感兴趣的:(Linear Congruence Equation(s))