草稿
作者:互联网
整数快速幂
#include <bits/stdc++.h>
using namespace std;
int quickpow(int x,int n){
int res=x,ans=1;
while(n){
if(n&1){
ans*=res;
}
res*=res;
n>>=1;
}
return ans;
}
int main()
{
int x,n;
scanf("%d%d",&x,&n);
printf("%d\n",quickpow(x,n));
//cout << "Hello world!" << endl;
return 0;
}
标签:std,草稿,int,res,printf,quickpow,ans 来源: https://www.cnblogs.com/-yjun/p/10426146.html