Rightmost Digit
题目链接:
http://acm.hdu.edu.cn/showproblem.php?pid=1061
解题思路:
快速幂。。。
AC代码:
#include <iostream>
#include <cstdio>
using namespace std;
int main(){
int T;
scanf("%d",&T);
while(T--){
int n;
scanf("%d",&n);
int tmp = n % 10;
int sum = 1;
while(n){
if(n&1)
sum = (sum*tmp) % 10;
tmp = (tmp*tmp)%10;
n >>= 1;
}
printf("%d\n",sum);
}
return 0;
}