fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int pxp(int x,int p){
  4. if(p==0) return 1;
  5. if(p%2) return x*pxp(x,p-1);
  6. int r=pxp(x,p/2);
  7. return r*r;
  8. }
  9. int main(){
  10. ios::sync_with_stdio(0); cin.tie(0);
  11. int x,y; cin>>x>>y;
  12. cout<<pxp(x,y); // x^y
  13. }
Success #stdin #stdout 0.01s 5284KB
stdin
2 5
stdout
32