码迷,mamicode.com
首页 > 其他好文 > 详细

快速乘法模版

时间:2017-09-15 12:15:23      阅读:100      评论:0      收藏:0      [点我收藏+]

标签:nbsp   amp   模版   turn   乘法   return   for   快速乘   ret   

 ll p;

ll kmul(ll a,ll b)
{
    ll ans=0;
    for(;b;)
    {
        if(b&1) ans=(ans+a)%p;
        a<<=1;
        a%=p;
        b>>=1;
    }
    return ans%p;
}

快速乘法模版

标签:nbsp   amp   模版   turn   乘法   return   for   快速乘   ret   

原文地址:http://www.cnblogs.com/chinacwj/p/7525335.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!