📜  二进制求幂 - C++ 代码示例

📅  最后修改于: 2022-03-11 14:44:49.150000             🧑  作者: Mango

代码示例1
long long binpow(long long a, long long b, long long m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}