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

逆元与组合数

时间:2020-03-15 00:04:40      阅读:56      评论:0      收藏:0      [点我收藏+]

标签:for   pow   ret   amp   code   合数   return   pre   power   

LL fpow(LL x, LL power, LL mod) 
{
    x %= mod;
    LL ans = 1;
    for (; power; power >>= 1, (x *= x) %= mod)
        if(power & 1) (ans *= x) %= mod;
    return ans;
}
LL qinv(LL a)
{
    LL x = fpow(a, mod - 2, mod);
    return x;
}

逆元与组合数

标签:for   pow   ret   amp   code   合数   return   pre   power   

原文地址:https://www.cnblogs.com/reshuffle/p/12495092.html

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