fork(1) download
  1. #include <iostream>
  2. #include <math.h>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. int t; // ilosc testów
  9. cin>>t;
  10. 1<= t <=10;
  11. for(int i=0; i<t; i++)
  12. {
  13. long long int a; // podstawa
  14. 1<= a <=100000000;
  15. long long int b; // wykładnik
  16. 1<= b <=100000000;
  17. cin >> a >>b;
  18. int c;
  19. if(b==4 || b==8)
  20. {
  21. c = int(pow(a,b));// wynik
  22. cout<<c%10<<endl;
  23. }
  24. else if(a==5 && b>1)
  25. {
  26. cout<<"5"<<endl;
  27. }
  28. else if(a==6 && b>1)
  29. {
  30. cout<<"6"<<endl;
  31. }
  32. else if(a==10 && b>1)
  33. {
  34. cout<<"0"<<endl;
  35. }
  36. else
  37. {
  38. c = int(pow(a,(b%4)));// wynik
  39. cout<<c%10<<endl;
  40. }
  41. }
  42. return 0;
  43. }
Success #stdin #stdout 0s 4260KB
stdin
4
10 6
4 8
2 0
7 7
stdout
0
6
1
3