经改进后代码如下:(输入a,k,m,求a^k%m)
long f(long a,long k,long m)
{
long b=1;
while(k>=1)
{
if(k%2==1) b=a*b%m;
a=a*a%m;
k=k/2;
}
return b;
}