fork(3) download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. long long int p, w;
  5. int ww, ile;
  6. int main()
  7. {
  8. cin>>ile;
  9. if ((ile<=1)||(ile>=10))return 0;
  10. for (int i=1; i<=ile; i++)
  11. {
  12. cin>>w>>p;
  13.  
  14.  
  15. if (p!=0){ // to chyba zbędne
  16. while (p>4)
  17. {
  18. p-=4;
  19. }
  20. if (p==1) ww=w;
  21. if (p==2) ww=w*w;
  22. if (p==3) ww=w*w*w;
  23. if (p==4) ww=w*w*w*w;
  24. cout << ww%10 << endl;
  25.  
  26. }
  27. else cout << 0 << endl;
  28. }
  29. return 0;
  30. }
  31.  
Success #stdin #stdout 0s 16048KB
stdin
1
8 9
stdout
Standard output is empty