运用分治,复杂度logn

 typedef long long LL;
 LL mod;
 
  LL f(LL a,LL b){
 	 if(b==1) return a;
 	 if(b==0) return 1;
 	 LL t=f(a,b/2);
 	 
    return b%2==0? t*t%mod : (((t*t)%mod)*a)%mod;
 }

posted on 2022-10-12 23:31  towboat  阅读(16)  评论(0)    收藏  举报