两个数相乘超long long乘法的取模

类似与快速幂的做法

View Code
/*===================================================================*\ 
| 两个数相乘超long long乘法的取模 mod的大小要十分注意
\*===================================================================*/
int multi_mod(int a,int b,int c) { //(a*b)%c 
    int ret=0;
    while(b) {
        if(b&1) { ret+=a; if(ret>=c) ret-=c; }
        a<<=1;  if(a>=c) a-=c;  b>>=1;
    }
    return ret;
} 
原文地址:https://www.cnblogs.com/zhang1107/p/2991396.html