TKO 1-2基本快速幂的基本操作(熟背)
作者:互联网
以余数为例:
#include
using namespace std;
int power(int a,int b,int p)
{
int ans=1%p;
for(;b;b>>=1){
if(b&1)
ans=(long long)ansa%p;
a=(long long)aa%p;
}
return ans;
}
int main(){
int a,b,p;
while(cin>>a&&a!=0){
cout<<“请输入指数:”<<endl;
cin>>b;
cout<<“请输入被取模数:”<<endl;
cin>>p;
int ret=power(a,b,p);
cout<<“所求余数为:”<<ret<<endl;
system(“pause”);
system(“cls”);
}
}
标签:cout,int,TKO,cin,long,system,熟背,ans,基本操作 来源: https://blog.csdn.net/wzwwzwwzw1200/article/details/116562060