求 a乘 b 对 p取模的值。

static long quick_multi(long a,long b,long m){
              long res=0;
              while(b>0){
                    if((b&1)==1) res=(res+a)%m;
                    b>>=1;
                    a=(a+a)%m;
              }
              return res%m;
        }
posted on 2020-01-18 13:28  qdu_lkc  阅读(206)  评论(0编辑  收藏  举报