原理参考:https://blog.csdn.net/qq_19782019/article/details/85621386
C++模板:
//求m的k次方关于p的模
int qmi(int m, int k, int p)
{
int res = 1 % p, t = m;
while (k)
{
if (k&1) res = res * t % p;
t = t * t % p;
k >>= 1;
}
return res;
}