fork download
  1. #include <iostream>
  2. using namespace std;
  3. int main () {
  4. int D;
  5. unsigned long long a, b, w;
  6. cin >> D;
  7. for (int i=1; i<=D; i++)
  8. {
  9. cin >> a >> b;
  10. if (1 <= a,b <= 1000000000)
  11. {
  12. a = a % 10;
  13. w = a;
  14. for (int j=1; j<=b-1; j++)
  15. {
  16. w = w * a;
  17. if (w>=10)
  18. w = w % 10;
  19. }
  20. }
  21. cout << w << endl;
  22. }
  23. }
Success #stdin #stdout 2.04s 4388KB
stdin
5
2 2
2 3
2 12
2 13
999999999 999999999
stdout
4
8
6
2
9