线性逆元

若求x关于p的逆元
设p=ax+b
则 a
x=-b(mod p)
所以 x-1=-ab-1
递推式 inv[x]=(p-p/x)
inv[p%x]

原文地址:https://www.cnblogs.com/hjmmm/p/9997626.html