power function

  1. ll power(ll a,ll b,ll mod){
  2. ll ans=1;
  3. while(b){
  4. if(b&1) ans=(ans*a)%mod;
  5. a=(a*a)%mod;
  6. b/=2;
  7. }
  8. return ans;
  9. }

Comments

Popular posts from this blog

Getting Started With MEAN App Development with AngularJs , ExpressJs , NodeJs and MongoDB.

B. Dreamoon and WiFi :calculate no. of ways : recursive solution (branch and bound )

A. Dreamoon and Stairs : minimum steps to reach : recursion solution.