快速幂取模

来源:互联网 发布:易语言安装包源码 编辑:程序博客网 时间:2024/06/03 18:15

刚学的快速幂取模,复习一下。

const LL mo=1e9+7;
LL mi_mo(LL a,LL b){
LL ans=1;
a%=mo;
while(b>0){
if(b%2==1)
ans=(ans*a)%mo;
a=(a*a)%mo;
b/=2;
}
return ans;
}