数论--费马小定理求逆元
生活随笔
收集整理的這篇文章主要介紹了
数论--费马小定理求逆元
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
ACM常用模板合集
int Fermat_inverse(int a,int mod) {int res = 1;for(int i = 1;i < mod - 1;++i) res *= a;return res; }//如果p為大素數,我們可以用快速冪求解,時間復雜度為:long long fast_pow_mod(long long a,long long b,long long mod) {long long res = 1;while(b){if(b & 1) res = (res * a) % mod;a = (a * a) % mod;b >>= 1;}return res; } long long Fermat_inverse(long long a,long long mod) {return fast_pow_mod(a,mod - 2,mod); }總結
以上是生活随笔為你收集整理的数论--费马小定理求逆元的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 怎么找域名解析的cname值
- 下一篇: 重庆服务器托管后怎么做好日常维护