fork download
  1. #include <iostream>
  2. using namespace std;
  3. const int mod = 1e9+7 ;
  4. long long power(int base, int n)
  5. {
  6. if(n==0) return 1;
  7.  
  8. if(n==1) return base ;
  9.  
  10.  
  11. long long x = (power(base, n/2));
  12.  
  13. if(n&1) return (x*x*base);
  14.  
  15.  
  16. return (x*x);
  17. }
  18. int main() {
  19. // your code goes here
  20. int n;
  21. cin>>n;
  22. cout<<power(2, 2)<<endl;
  23. return 0;
  24. }
Success #stdin #stdout 0.01s 5432KB
stdin
4
5
6
7
8
9
stdout
4