fork download
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <cmath>
  4. #include <string>
  5.  
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10.  
  11. int t, a, b, wynik;
  12. char result[100];
  13. cin >> t;
  14. for (int i = 0; i < t; i++) {
  15. cin >> a >> b;
  16. wynik = pow(a, b);
  17. string str = to_string(wynik);
  18. int dl = str.length();
  19. result[i] = str[dl - 1];
  20. }
  21. for (int i = 0; i < t; i++) {
  22. cout << result[i] << endl;
  23. }
  24.  
  25.  
  26.  
  27.  
  28.  
  29. cin.get();
  30. cin.ignore();
  31. return 0;
  32. }
Success #stdin #stdout 0s 16064KB
stdin
1
5 2
11 2
5 5
stdout
1