快速幂 A^B Mod C
作者:互联网
C语言——A^B Mod C
在这里插入代码片
```#include<stdio.h>
long long pow(long long a,long long b,long long c){
long long s=1;
while(b){
if(b%2) s*=a;
a=(a*a)%c;
b=b/2;
s=s%c;
}
return s;
}
int main()
{
long long a,b,c;
scanf("%lld %lld %lld",&a,&b,&c);
a%=c;
printf("%lld",pow(a,b,c));
}
标签:b%,main,pow,long,Mod,快速,lld 来源: https://blog.csdn.net/weixin_61253481/article/details/122507700