fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. typedef unsigned long long int ull;
  5. double g(double a) {return a*a;}
  6. double f(double a, ull n) {return n==1 ? a : n%2 ? a*f(a,n-1) : g(f(a,n/2));}
  7.  
  8. double MyPow(double a, ull n)
  9. {
  10. double t=1.0;
  11. for(ull i=1;i<=n;i++)
  12. t*=a;
  13. return t;
  14. }
  15.  
  16. int main() {
  17. double a = 1.000000005; ull n = 2000000000;
  18. cout << f(a,n) << endl;
  19. //cout << MyPow(a,n) << endl;
  20. return 0;
  21. }
Success #stdin #stdout 0s 3412KB
stdin
Standard input is empty
stdout
22026.5