题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=1061
#include <iostream> using namespace std; int most_right_NN(__int64 N) { int result =1; int temp = N%10; if(temp == 0) return 0; while(N) { if(N & 0x01) result =(result *temp)%10; //等价相乘取余数,防止溢出 temp = (temp*temp)%10; N=N>>1; } return result; } int main() { int T,begin,end; int length; int i,j; __int64 N; int result; while(scanf("%d",&T)!=EOF) { for(j =0;j <T;j++) { scanf("%I64d",&N); result = most_right_NN(N); printf("%d\n",result); } } return 0; }