#import  gmpy2

'''
Given the following set of linear congruences:

x ≡ 2 mod 5
x ≡ 3 mod 11
x ≡ 5 mod 17

Find the integer a such that x ≡ a mod 935
'''

from Crypto.Util.number import *

def Chinese(n, N, a):
    result = 0

    for i in range(len(n)):
        ai = a[i]
        ni = n[i]
        bi = N // ni

        result += ai * bi * inverse(bi, ni)

    return result % N

N=935
n=[5,11,17]
a=[2,3,5]
result=Chinese(n,N,a)
print(result)
