def chinese(a, m, num):
_M = reduce(lambda a, b: a * b, m)
M = [_M // m[k] for k in range(num)]
x = sum([a[i] * M[i] * gmpy2.invert(M[i], m[i]) % _M for i in range(num)]) % _M
return x
中国剩余定理
最新推荐文章于 2020-08-24 20:36:31 发布