NYOJ 473 A^B Problem
地址:http://acm.nyist.net/JudgeOnline/problem.php?pid=473
1 #include <stdio.h> 2 int main() 3 { 4 int a,b; 5 int i; 6 while(scanf("%d%d",&a,&b)!=EOF) 7 { 8 if(b==0) 9 printf("1\n"); 10 else 11 { 12 a%=10; 13 b=b%4+4; 14 int s=a; 15 for(i=1;i<b;i++) 16 s*=a; 17 s%=10; 18 printf("%d\n",s); 19 } 20 } 21 return 0; 22 }