fork(2) download
  1. #include <iostream>
  2. #include <sstream>
  3. using namespace std;
  4. int t,a,b,dlugosc,wynik;
  5. long int potega (int p,int w)
  6. {
  7. if(w==0)return 1;
  8. else return p*potega(p,w-1);
  9. }
  10. int main()
  11. {
  12. cin >> t;
  13. for(int i=0;i<t;i++)
  14. {
  15. cin >> a >> b;
  16. wynik=potega(a,b);
  17. if(wynik<10)
  18. cout << wynik << endl;
  19. else
  20. {
  21. int i = wynik;
  22. ostringstream ss;
  23. ss << i;
  24. string str = ss.str();
  25. int dlugosc=str.length();
  26. for(int i=0;i<=dlugosc;i++)
  27. {
  28. if(dlugosc==i)
  29. {
  30. str.erase(0,i-1);
  31. cout << str << endl;
  32. }
  33. }
  34. }
  35. }
  36. return 0;
  37. }
Success #stdin #stdout 0s 16064KB
stdin
10
2 5
3 5
3 4
6 8
6 2
6 4
7 8
24 5
5 7
8 4
stdout
2
3
1
6
6
6
1
4
5
6