快速幂函数

来源:互联网 发布:sub数学 知乎 编辑:程序博客网 时间:2024/05/01 13:58
快速幂函数__int64 multimod(__int64 x, __int64 n, __int64 mod){    __int64 tmp = x, res = 1LL;    while (n)    {        if (n & 1LL)        {            res *= tmp;            res %= mod;        }        tmp *= tmp;        tmp %= mod;        n >>= 1LL;    }    return res;}
0 0
原创粉丝点击