fork download
  1. #include <iostream>
  2. #define N 20
  3. using namespace std;
  4. unsigned int potega(int a, int b);
  5. int main()
  6. {
  7. int D,a,b,c;
  8. unsigned int wyniki[N];
  9. cin >> D;
  10. for(int i=0;i<D;i++){
  11. cin >> a >> b;
  12. int c = b%4;
  13. if(b>0 && c>0)
  14. b=c;
  15. wyniki[i] = potega(a,b);
  16. }
  17.  
  18. for(int i=0;i<D;i++){
  19. cout << wyniki[i]%10 << endl;
  20. }
  21. }
  22. unsigned int potega(int a, int b){
  23. if(b==0)
  24. return 1;
  25. else
  26. return a=a*potega(a,--b);
  27. }
  28.  
Success #stdin #stdout 0s 3472KB
stdin
4
2 10
2 4
2 0
2 1
stdout
4
6
1
2