您的位置:首页 > 其它

【杭电1061】Rightmost Digit

2016-07-23 15:47 337 查看




#include<stdio.h>
int quickpow(int a,int b) {
int ans=1,base=a%10;//此处%10
while(b) {
if(b&1) {
ans=ans*base%10;
}
base=base*base%10;
b>>=1;
}
return ans;
}
int main() {
int T;
scanf("%d",&T);
while(T--) {
__int64 n;
scanf("%d",&n);
printf("%d\n",quickpow(n,n));
}
return 0;
}


http://acm.hdu.edu.cn/showproblem.php?pid=1061
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  杭电