include
using namespace std;
int power(int a , int b){ if(!b)return 1; if(b == 1)return a; int res = power(a,(b>>1)); if(b&1) return a*res*res; else return res*res; }
int main() { int a , b; cin>>a>>b; cout<<power(a,b); return 0; }
Fast Exponentiation C++ Program
using namespace std;
int power(int a , int b){ if(!b)return 1; if(b == 1)return a; int res = power(a,(b>>1)); if(b&1) return a*res*res; else return res*res; }
int main() { int a , b; cin>>a>>b; cout<<power(a,b); return 0; }
| Rev. | Lang. | By | When | Δ | Comment | |
|---|---|---|---|---|---|---|
| en1 |
|
prajal_patidar | 2021-09-05 21:41:48 | 343 | Initial revision (published) |