Подключение
Базовый URL, учётные данные и доступный сервер.
Проверьте предположение о взаимной простоте в congruences.py перед использованием общего остатка в расписании или индексе.
Базовый URL, учётные данные и доступный сервер.
Модель, которую предоставляет настроенный endpoint.
Объём контекста и поддержка инструментов определяются моделью и сервером.
import math
def merge_congruences(pairs):
if type(pairs) is not list or len(pairs) > 8:
raise ValueError("crt.input")
answer, period = 0, 1
for pair in pairs:
if type(pair) not in (list, tuple) or len(pair) != 2 or any(type(x) is not int for x in pair):
raise ValueError("crt.pair")
residue, modulus = pair
if abs(residue) > 10**9 or not 2 <= modulus <= 10**6 or math.gcd(period, modulus) != 1:
raise ValueError("crt.modulus")
step = ((residue-answer)*pow(period, -1, modulus)) % modulus
answer += period*step
period *= modulus
answer %= period
return answer, period