摘要:
Problem - 1004 (hdu.edu.cn) 扩展欧几里得解决线性同余方程。先得到gcd的解,再恢复原解,因为知道通解的一般形式,所以通过模来得到最小正整数解。另一个可以通过相减,或者一样的操作。一个增加,另一个一定减少。 #include<bits/stdc++.h> using nam 阅读全文
posted @ 2021-07-14 21:32
mofan552
阅读(47)
评论(0)
推荐(0)
摘要:
Problem - 1003 (hdu.edu.cn) n次求逆元,线性求逆元 要用long long,不然很容易炸 每次叠加,不停的取模 必须互素,必须为质数。 不足的不会出现0,而后面的则满足取模的意义 #include<bits/stdc++.h> using namespace std; c 阅读全文
posted @ 2021-07-14 16:47
mofan552
阅读(54)
评论(0)
推荐(0)
摘要:
同样求逆元的题目,费马的条件,首先要保证p为质数,然后保证a与p互素。 数据范围问题,要保证在数据范围内,所以要b先模上mod #include<bits/stdc++.h> using namespace std; const int mod=9973; int qmi(int a,int b) 阅读全文
posted @ 2021-07-14 00:19
mofan552
阅读(31)
评论(0)
推荐(0)
摘要:
求逆元板子题,费马小定理求逆元,快速幂,维护前缀积。 #include<bits/stdc++.h> using namespace std; //bool isprime(int x) //{ // if(x==1) return false; // if(x==2) return true; / 阅读全文
posted @ 2021-07-14 00:11
mofan552
阅读(25)
评论(0)
推荐(0)

浙公网安备 33010602011771号