分数取模

a^-1 mod p 就是 我们要求的,这个值的结果恒等于  a^p-2 mod p

inline int ksm(int x,int y){
    int ans1=1;while (y){
        if (y&1) ans1=1ll*ans1*x%Mod;
        y>>=1;x=1ll*x*x%Mod;
    }return ans1;
}

比如E/V 对MOD 取余就是  E*ksm(V,MOD-2)%MOD;

posted @ 2019-07-06 09:48  厂长在线养猪  Views(261)  Comments(0Edit  收藏  举报