快速乘模板

于是在做miller算法的过程中顺便学了一下快速乘..

没什么可说的了吧,代码如下

 

ll qmulti(ll a,ll b,ll c)
{
    ll tem=a,sum=0;
    while(b)
    {
        if(b&1)sum=(sum+tem)%c;
        tem=(tem+tem)%c;
        b>>=1;
    }
    return sum;
} 

 

  

 

posted @ 2017-09-13 22:35  a799091501  阅读(90)  评论(0编辑  收藏  举报