![](https://img-blog.csdnimg.cn/20201014180756916.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
数论
文章平均质量分 57
Unin88
这个作者很懒,什么都没留下…
展开
-
POJ 2635 The Embarrassed Cryptographer
http://poj.org/problem?id=2635 高精度取mo原创 2014-11-19 14:39:42 · 372 阅读 · 0 评论 -
C. Hacking Cypher
http://codeforces.com/contest/490/problem/C #include #include #include #include using namespace std; const int MAX = 1000010; char str[MAX]; int a,b; int ma[MAX],mb[MAX]; long long Pow(原创 2014-11-25 21:21:08 · 430 阅读 · 0 评论 -
hdu 1576 A/B
http://acm.hdu.edu.cn/showproblem.php?pid=1576 此题是裸扩展gcd 设A/B=x; A%9973=n即 A = 9973*k + n 即B*x-9973*k=n 一个基本的同余方程,利用扩展gcd求解x即可。 #include #include #include #include using namespace std;原创 2014-11-26 22:01:56 · 468 阅读 · 0 评论 -
Modular Equations
http://codeforces.com/contest/495/problem/B a mod x = b等价于(a-b)%x=0那么就容易思考解决,不过我没想到这个也做出来了! AC代码: #include #include #include #include #include using namespace std; int main(){ int a,原创 2014-12-17 16:10:01 · 615 阅读 · 0 评论 -
SGU 116 Index of super-prime
素数筛+完全背包+路径记录 AC代码: #include #include #include #include #include using namespace std; const int MAX = 100010; const int INF = 0x3f3f3f3f; bool IsPrime[MAX]; int Prime[MAX],SPrime[MAX],pn,cnt原创 2014-12-16 17:01:15 · 367 阅读 · 0 评论 -
SGU 106 The equation
http://acm.hust.edu.cn/vjudge/contest/view.action?cid=65432#problem/F 通过题目的数据范围10^8可知需要一个logn级别的算法来解决本题目,那么显而易见应用扩展gcd来解决,写起来可谓是treak多多! 1.扩展gcd算法 LL exGcd(LL a, LL b, LL &x, LL &y){ if(b =原创 2014-12-07 13:08:49 · 371 阅读 · 0 评论 -
POJ 1061 青蛙的约会
http://poj.org/problem?id=1061 (t*m + x) - (y + t*n) = k * L t*(m-n) - k*L = y - x 由此使用扩展gcd来解不定方程! #include #include #include #include using namespace std; typedef long long LL; LL原创 2014-12-07 14:35:38 · 313 阅读 · 0 评论 -
HDU 1695 GCD(欧拉函数+容斥原理)
http://acm.hdu.edu.cn/showproblem.php?pid=1695 [1,b]中选择一个x,[1,d]中选择一个y,使得gcd(x,y) = k问题等价于在[1,b/k],[1,d/k]中选择x,y使得gcd(x,y) = 1 我们保证b小于d,那么就可以遍历[1,d/k]这个区间得到所有满足条件的素数对. 分为两种情况: 1.[1,b]时直接使用欧拉定理原创 2014-12-07 20:32:00 · 532 阅读 · 0 评论 -
POJ 2115 C Looooops
http://poj.org/problem?id=2115 推出同余方程:C*x - 2^k*y = B -A直接使用扩展gcd求解! #include #include #include #include #include using namespace std; typedef long long LL; LL exGcd(LL a, LL b, LL &x,原创 2014-12-07 22:11:53 · 341 阅读 · 0 评论