fork(1) download
  1. #include <iostream>
  2. #include <cmath>
  3. #include <string>
  4.  
  5. using namespace std;
  6.  
  7. unsigned int* a, *b;
  8.  
  9. int main()
  10. {
  11. int i;
  12.  
  13. cin >> i;
  14. a = new unsigned int[i];
  15. b = new unsigned int[i];
  16.  
  17. if (i > 0)
  18. {
  19. for (unsigned int j = 0; j < i; j++)
  20. {
  21. cin >> a[j] >> b[j];
  22. }
  23. for (unsigned int j = 0; j < i; j++)
  24. {
  25. if (b[j] == 0)
  26. {
  27. cout << 1 << endl;
  28. }
  29. else if (a[j] == 0)
  30. {
  31. cout << 0 << endl;
  32. }
  33. else
  34. {
  35. string liczbaJednosci = to_string((int)pow(a[j], b[j]));
  36. cout << liczbaJednosci[liczbaJednosci.length() - 1] << endl;
  37. }
  38. }
  39. }
  40. }
Success #stdin #stdout 0.01s 5548KB
stdin
2
2 3
3 3
stdout
8
7