fork(1) download
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. using namespace std;
  5.  
  6. int ile;
  7.  
  8. int main()
  9. {
  10. cin >> ile;
  11.  
  12. for(int i=0; i<ile; i++)
  13. {
  14. long long int a, b, e, h;
  15. int c, d, f, g, k;
  16. cin >> a >> b;
  17.  
  18. if(a == 5) cout << 5 << endl;
  19. else if(a == 6) cout << 6 << endl;
  20. else
  21. {
  22. g = a%10;
  23. c = b/4;
  24. d = b-c*4;
  25. e = pow(g,d);
  26. f = e%10;
  27. cout << f << endl;
  28. }
  29. }
  30.  
  31. return 0;
  32. }
  33.  
Success #stdin #stdout 0s 3472KB
stdin
11
1289312391 0
1 2321323123
2 324324345
3 435435436
4 9080237
5 2163062
6 96123412
7 921638125
8 2128963591
9 21538123
0 182931253
stdout
1
1
2
1
4
5
6
7
2
9
0