fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. int n, a, b;
  5.  
  6.  
  7. long int potega(int a, int b)
  8. {
  9. if(b==0) return 1;
  10. else return a*potega(a, b-1);
  11. }
  12. int main()
  13. {
  14. cin>>n;
  15. for(int i=1; i<=n; i++)
  16. {
  17. cin>>a>>b;
  18. cout<<potega(a,b)%10<<endl;
  19. }
  20. return 0;
  21. }
  22.  
Success #stdin #stdout 0s 3468KB
stdin
Standard input is empty
stdout
Standard output is empty