随笔分类 - HDU
摘要:https://acm.hdu.edu.cn/showproblem.php?pid=3579 一些坑点。首先是如果说最后求得到的结果为0,那么在数学意义上这是正确的,0对于任何的确是最小的整数解,但实际意义正整数就并非如此了,如果为0,那么下一个最小解为最小公倍数。 一个技巧,先除再乘防止爆炸。
阅读全文
摘要:https://acm.hdu.edu.cn/showproblem.php?pid=1573 n组线性同余方程求解,最后求出多少解。而最终的解的周期为最小公倍数,范围内的,需要这样算。如果最小超过,那么直接是0,如果无解为0,如果最小为0,那么直接为k个lcm,否则要加上自身的1,因为要求为正整数
阅读全文
摘要:https://oj.shiyancang.cn/Problem/798.html #include<bits/stdc++.h> using namespace std; typedef long long ll; const int mod = 21252; ll a[4],m[4]; ll M
阅读全文
摘要:https://acm.hdu.edu.cn/showproblem.php?pid=2098 时间复杂度 #include<bits/stdc++.h> using namespace std; typedef long long ll; const ll N=2e4+520; bool st[N
阅读全文
摘要:Problem - 1004 (hdu.edu.cn) 扩展欧几里得解决线性同余方程。先得到gcd的解,再恢复原解,因为知道通解的一般形式,所以通过模来得到最小正整数解。另一个可以通过相减,或者一样的操作。一个增加,另一个一定减少。 #include<bits/stdc++.h> using nam
阅读全文
摘要:Problem - 1003 (hdu.edu.cn) n次求逆元,线性求逆元 要用long long,不然很容易炸 每次叠加,不停的取模 必须互素,必须为质数。 不足的不会出现0,而后面的则满足取模的意义 #include<bits/stdc++.h> using namespace std; c
阅读全文
摘要:同样求逆元的题目,费马的条件,首先要保证p为质数,然后保证a与p互素。 数据范围问题,要保证在数据范围内,所以要b先模上mod #include<bits/stdc++.h> using namespace std; const int mod=9973; int qmi(int a,int b)
阅读全文
摘要:求逆元板子题,费马小定理求逆元,快速幂,维护前缀积。 #include<bits/stdc++.h> using namespace std; //bool isprime(int x) //{ // if(x==1) return false; // if(x==2) return true; /
阅读全文