hdu 1097 用到了位的移动


 

#include"stdio.h"
int qpow(int a,int b)
{
int s=1;
while(b)
{
if(b%2)s=(s*a)%10;
a=(a*a)%10;
b=b>>1;

}
return s%10;
}

int main( )
{
int a,b;
while(scanf("%d%d",&a,&b)==2)
{
printf("%d\n",qpow(a%10,b));
}
return 0;
}
原文地址:https://www.cnblogs.com/chaosheng/p/2334053.html