fork(1) download
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. int pot(double &a, double &b)
  6. {
  7. int tmp=0;
  8. unsigned long long licz=1;
  9. cin >> a >> b;
  10. if(a >=1 && b <=1000000000)
  11. {
  12. if( b == 0)
  13. licz =1;
  14. else if(b != 0)
  15. {
  16. for(int i=0; i<b; i++)
  17. {
  18. licz *= a;
  19.  
  20. }
  21. }
  22. tmp = licz%10;
  23. }
  24.  
  25. return tmp;
  26. }
  27. int main()
  28. {
  29. int n;
  30. double a=0,b=0;
  31. cin>>n;
  32. if(n >= 1 && n<=10)
  33. {
  34. for(int i=0; i<n; ++i)
  35. {
  36. cout <<pot(a,b) << endl;
  37. }
  38. }
  39. return 0;
  40. }
Success #stdin #stdout 0s 3472KB
stdin
2
3 4
3 3
stdout
1
7