码迷,mamicode.com
首页 >  
搜索关键字:baby_step    ( 40个结果
数论之高次同余方程(Baby Step Giant Step + 拓展BSGS)
什么叫高次同余方程?说白了就是解决这样一个问题: A^x=B(mod C),求最小的x值。 baby step giant step算法 题目条件:C是素数(事实上,A与C互质就可以。为什么?在BSGS算法中是要求a^m在%c条件下的逆元的,如果a、c不互质根本就没有逆元。) 如果x有解,那么0<=
分类:其他好文   时间:2016-02-02 22:25:21    阅读次数:296
poj 2417 Discrete Logging(A^x=B(mod c),普通baby_step)
http://poj.org/problem?id=2417A^x = B(mod C),已知A,B。C。求x。这里C是素数,能够用普通的baby_step。在寻找最小的x的过程中,将x设为i*M+j。从而原始变为A^M^i * A^j = B(mod C),D = A^M,那么D^i * A^j ...
分类:其他好文   时间:2016-01-01 13:02:34    阅读次数:243
Baby-Step-Giant-Step 很酷的算法
Baby-Step-Giant-Step BSGS算法用于解决形如: A ^ x ≡ B ( mod C ) 的问题。 学这个算法前需要具备以下知识:快速幂取模、扩展欧几里得、同余知识、哈希表(也可以用map,不过更耗时).. 一. 普通的Baby-Step-Giant-S...
分类:编程语言   时间:2015-08-29 16:37:48    阅读次数:428
poj 2417 Discrete Logging 数论baby_step,giant_step算法
题意: 给p,b,n求最小的l使b^l==n(mod p)。 题意: 相当于在0~p-1内搜索l满足同余式,baby_step,giant_step相当于分块的二分搜索,设m=sqrt(p), 则将p分为m*m,在m块内每块进行m个数的二分搜索。 代码://poj 2417 //sep9 #include #include #include using namespace std; ...
分类:编程语言   时间:2015-04-15 17:11:42    阅读次数:174
扩展baby step giant step模版
#include #include #include #include using namespace std; typedef __int64 LL; LL gcd(LL a, LL b) { return b ? gcd(b, a%b) : a; } LL pow_mod(LL a, LL p, LL n) { LL ans = 1; while(p) { if(p&1) ...
分类:其他好文   时间:2015-03-16 17:51:51    阅读次数:164
POJ 2417 Discrete Logging Baby-Step-Gaint-Step
题目大意:给出A,B,C,求A^x=B(mod C)的最小x的值。 思路:著名的BSGS算法。将C拆分成根号块,先对一个根号内的东西暴力插入一个Hash表中(别问我为什么不用map,因为这个题卡map。。。 另我们要求的x=i * m + j,原式可以写成A^(i * m) * A^j = B(mod C)。这是ax=b(mod c)的形式我们只需要枚举i,然后看有没有符合要求的j就可...
分类:其他好文   时间:2015-02-26 16:44:29    阅读次数:141
离散对数,giant-step baby-step,拓展giant-step baby-step (poj 2417, hdu 2815)
离散对数,giant-step baby-step,拓展giant-step baby-step (poj 2417, hdu 2815) 普通giant-step baby-step: poj 2417 题意: B^L==N(MOD P), 给出P,B,N, 求最小的非负L。 限制: 2 思路: 离散对数,用giant-step baby-step解...
分类:其他好文   时间:2015-02-05 16:25:46    阅读次数:159
HDU 2815 扩展baby step giant step 算法
题目大意就是求 a^x = b(mod c) 中的x用一般的baby step giant step 算法会超时这里参考的是http://hi.baidu.com/aekdycoin/item/236937318413c680c2cf29d4map平衡树查找值 1 #include 2 #incl....
分类:编程语言   时间:2015-02-02 01:53:56    阅读次数:252
BZOJ3239 Discrete Logging
一道裸的BSGS题目(叫baby step, giant step)从爱酱的blog里学来的,是一个很神的根号算法。如果我们有hash的工具的话,就是O(sqrt(p))的,这里又用了一个map所以是O(sqrt(p) * log(sqrt(p))) 1 /*********************...
分类:其他好文   时间:2015-01-30 22:15:38    阅读次数:123
BZOJ 3239 Discrete Logging Baby-Step-Giant-Step
题目大意:给定P,B,N,求最小的L使B^L≡N (mod P) (P是质数) 裸的BSGS。。。 练练手吧- - #include #include #include #include #include #define M 100100 #define INF 0x3f3f3f3f using namespace std; typedef pair abcd; long long ...
分类:其他好文   时间:2015-01-20 12:07:39    阅读次数:204
40条   上一页 1 2 3 4 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!