标签:
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 38642 Accepted Submission(s): 14558
1 #include <iostream> 2 #include <cstring> 3 #include <cstdio> 4 #include <cmath> 5 using namespace std; 6 7 int pow1(int x, int n) 8 { 9 __int64 ans = 1, t = n; 10 while(n) 11 { 12 if(n & 1) 13 { 14 ans = (ans * t) % 10; 15 } 16 t = t * t % 10; 17 n >>= 1; 18 } 19 return ans; 20 } 21 int main() 22 { 23 __int64 n, m; 24 scanf("%d", &n); 25 for(int i = 0; i < n; i++) 26 { 27 scanf("%d", &m); 28 printf("%d\n", pow1(m, m) % 10); 29 } 30 }
标签:
原文地址:http://www.cnblogs.com/vincentX/p/4575739.html