计算分数n/m对c取模
long long int c; long long int quick(long long int n,long long int m) { long long int ans=1; n=n%c; while(m>0) { if(m&1) ans=(ans*n)%c; n=(n*n)%c; m>>=1; } return ans; } int main() { long long int n,m; cout<<(n)*quick(m,c-2)%c<<endl; }
标签:int log quic col while ret style span UI
计算分数n/m对c取模
long long int c; long long int quick(long long int n,long long int m) { long long int ans=1; n=n%c; while(m>0) { if(m&1) ans=(ans*n)%c; n=(n*n)%c; m>>=1; } return ans; } int main() { long long int n,m; cout<<(n)*quick(m,c-2)%c<<endl; }
标签:int log quic col while ret style span UI
原文地址:https://www.cnblogs.com/ww123/p/8729002.html