fork(1) download
  1. #include <iostream>
  2. #include <math.h>
  3.  
  4. using namespace std;
  5. int a,b,d;
  6. int p;
  7.  
  8. int main()
  9. {
  10. cin>>d;
  11. cout<<endl<<endl;
  12.  
  13. for(int i=0; i<d; i++)
  14. {
  15. cin>>a>>b;
  16.  
  17. a=a%10;
  18.  
  19. if (b%4==0)
  20. b=4;
  21. else
  22. b=b%4;
  23.  
  24. p=pow(a,b);
  25.  
  26. cout<<p%10<<endl<<endl;
  27.  
  28. }
  29.  
  30. return 0;
  31. }
  32.  
Success #stdin #stdout 0s 4548KB
stdin
Standard input is empty
stdout