快速幂,a的b次方;
LL sm(LL a, LL b){ LL ans = 1; a = a%mod; while (b > 0) { if (b % 2 == 1) ans = (ans*a) % mod; b = b / 2; a = (a*a) % mod; } return ans%mod;}
本文共 258 字,大约阅读时间需要 1 分钟。
快速幂,a的b次方;
LL sm(LL a, LL b){ LL ans = 1; a = a%mod; while (b > 0) { if (b % 2 == 1) ans = (ans*a) % mod; b = b / 2; a = (a*a) % mod; } return ans%mod;}
转载于:https://www.cnblogs.com/yuanbo123/p/5717633.html