fork(2) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. long pow(long a, long b) {
  5. if(b==0){
  6. return 1;
  7. }
  8. if(b%2==0){
  9. return pow(a * a, b / 2);
  10. }
  11. return a * pow(a, b - 1);
  12. }
  13.  
  14. int main() {
  15. long a, b;
  16. cin >> a >> b;
  17. cout << pow(a,b);
  18. return 0;
  19. }
Success #stdin #stdout 0s 4500KB
stdin
12
stdout
2