1 #include <stdio.h> 2 #include <math.h> 3 int main() 4 { 5 int Num1,Num2; 6 while(scanf("%d %d",&Num1,&Num2)!=EOF) 7 { 8 printf("%d ",getLastNum(Num1,Num2)); 9 } 10 return 0; 11 } 12 // 求a的b次幂最后一位数字为什么 13 int getLastNum(int a, int b) 14 { 15 int n = b%4; 16 int x = a%10; 17 int lastNum = 0; 18 if(n == 0) 19 { 20 lastNum = pow(x,4); 21 } 22 else 23 { 24 lastNum = pow(x,n); 25 } 26 lastNum = lastNum%10; 27 return lastNum; 28 }