a = (seed2 - seed1) * gmpy2.invert(seed1 - seed0, m) % m b = (seed1 - a * seed0) % m
MMI = lambda A, m, s=1, t=0, N=0: (m < 2and t % N or MMI(m, A % m, t, s - A // m * t, N or m), -1)[m < 1] # 逆元计算 ani = MMI(a, m) seed = seed2 for i inrange(3): seed = (ani * (seed - b)) % m print(long_to_bytes(seed))