Linear Congruence Equation:
Chinese Remainder Theore
Linear Congruence Equations:
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;