int powMod(int a, int b, int mod){
int res = 1;
while (b){
if (b&1) res = (res*a) % mod;
a = (a*a) % mod;
b >>= 1;
}
return res;
}
快速幂
最新推荐文章于 2024-05-21 23:34:41 发布
int powMod(int a, int b, int mod){
int res = 1;
while (b){
if (b&1) res = (res*a) % mod;
a = (a*a) % mod;
b >>= 1;
}
return res;
}