fork download
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. using namespace std;
  5. int a,b,ile;
  6. unsigned long c;
  7.  
  8. int main()
  9. {
  10. cin>>ile;
  11. for(int i=0; i<ile; i++)
  12. {
  13. cin>>a;
  14. cin>>b;
  15. c=pow(a,b);
  16. if(c<10)
  17. {
  18. cout<<c<<endl;
  19. }
  20. else
  21. {
  22. cout<<c%10<<endl;
  23. }
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34. }
  35. return 0;
  36. }
Success #stdin #stdout 0s 4268KB
stdin
5
5 1
5 2
5 3
5 4
5 5
stdout
5
5
5
5
5