
逆元
syyyyyw
acmer一枚
展开
-
UVALive 7720
错了很久是因为要去求逆元 同余模定理不适合除法 举个例子 30/2Mod4=(15)Mod4=3; 要分开模就是1 必须要用费马小定理来求 在模为素数p的情况下,有费马小定理 a^(p-1)=1(mod p) 那么a^(p-2)=a^-1(mod p) 也就是说a的逆元为a^(p-2) 剩下的就是快速幂取模 long long pow4(int a,int原创 2017-08-20 18:49:11 · 300 阅读 · 0 评论 -
2017 ACM-ICPC 亚洲区(西安赛区)网络赛 B coin
数学能力严重退化,奇数项的和都不会求了。。 代码如下 #include #include #include #include using namespace std; const int M=1e9+7; long long pow4(int a,int b) { long long base=a,r=1; while(b){ if(b&1)原创 2017-09-16 19:06:48 · 196 阅读 · 0 评论