b 值大,取二分幂计算
#include <stdio.h> #include <string.h> #define M int main(int argc, char* argv[]) { #ifdef __MYLOCAL freopen("in.txt","r",stdin); #endif int a,b,c,t; while(scanf("%d%d",&a,&b) != EOF) { c = 1, t = a % 10; while(b > 0) { b % 2 == 1 ? c = c * t % 10 : NULL; b >>= 1; t = t * t % 10; } printf("%d ",c); } return 0; }