// one
typedef long long ll;
ll mod_pow(ll x, lln, ll mod) {
ll res = 1;
while (n > 0) {
if (n & 1) res = x * x % mod;
x = x * x % mod;
n >>= 1;
}
return res;
}
//two
ll mod_pow(ll x, ll n, ll mod) {
if (n == 0) return 1;
ll res = mod_pow(x * x % mod, n / 2, mod);
if (n & 1) res = res * x % mod;
return res;
}
快速幂运算
最新推荐文章于 2020-08-03 08:42:06 发布