快速幂(O(log n))
代码:
LL quick_pow(LL a , LL k , LL p)
{
LL res = 1;
while(k)
{
if(k & 1) res = (res * a) % p;
a = (a * a) % p;
k >>= 1;
}
return res;
}
龟速乘(O(log n))
代码:
LL quick_add(LL a , LL b , LL p)
{
LL res = 0;
while(b)
{
if(b & 1) res = (res + a) % p;
a = (a + a) % p;
b >>= 1;
}
return res;
}
QwQ