fork(1) download
  1. #include <iostream>
  2. #include <sstream>
  3. #include <string>
  4. using namespace std;
  5.  
  6.  
  7. int main()
  8. {
  9.  
  10. int D;
  11.  
  12. cin>>D;
  13.  
  14. for(int i=0; i<D; i++)
  15. {
  16. unsigned long long a, b;
  17.  
  18. //cin.clear();
  19. // cin.sync();
  20.  
  21. cin>>a>>b;
  22. unsigned long long wynik=1;
  23.  
  24. if(a==0) cout << 0<<endl;
  25. if(b==0) cout<<1<<endl;
  26. else
  27. {
  28.  
  29. for(int j=0; j<b; j++)
  30. {
  31. wynik=wynik*a;
  32. }
  33. }
  34. // << "wynik: "<< wynik << endl;
  35.  
  36. string ost_cyfra;
  37. stringstream ss;
  38. ss<<wynik;
  39. ss>>ost_cyfra;
  40. int dlugosc=ost_cyfra.length();
  41.  
  42. cout << ost_cyfra[dlugosc-1]<<endl;
  43.  
  44. }
  45.  
  46.  
  47.  
  48. return 0;
  49. }
  50.  
Success #stdin #stdout 0s 3468KB
stdin
4
2 3
3 3
1000002 2
1 000 000 000 2
stdout
8
7
4
1
1