fork(6) download
  1. #include <iostream>
  2. #include <cmath>
  3. #include <string>
  4. using namespace std;
  5. int main()
  6. {
  7. int t, i,j,a,b;
  8. //double a, b;
  9. cin >> t;
  10. for (i = 0; i < t; i++)
  11. {
  12. cin >> a >> b;
  13. int p = pow(a, b);
  14. string s = to_string(p);
  15. for (j = 0; j <= s.length(); j++)
  16. {
  17. char x = s[j];
  18. if (j == s.length()-1)
  19. {
  20. cout << x << endl;
  21. }
  22. }
  23. }
  24. return 0;
  25. }
  26.  
Success #stdin #stdout 0s 4772KB
stdin
3
2 3
10 2
4 2
stdout
8
0
6