码迷,mamicode.com
首页 >  
搜索关键字:baby-step-giant-step    ( 34个结果
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
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
Baby Step Gaint Step
给定同余式,求它在内的所有解,其中总是素数。分析:解本同余式的步骤如下 (1)求模的一个原根 (2)利用Baby Step Giant Step求出一个,使得,因为为素数,所以有唯一解。 (3)设,这样就有,其中,那么得到。 (4)求出所有的,可以知道一共有个解,我们求出所有的,然后排个序即...
分类:其他好文   时间:2014-10-29 16:36:21    阅读次数:250
POJ2417 Baby-Step-Gaint-Step 算法
考虑一个问题:A^x%p=B,给定A,B,p,求x的最小非负整数解。 在p是质数的情况下,这个问题比较简单。 A^x=B(mod P) (P is a Prime, A,B Let m = floor(sqrt(P)) Put A^0,A^1,...A^(m-1) into HashSet(You Can Also Use Map in STL),for Example M[A^i]=i....
分类:编程语言   时间:2014-10-28 13:55:30    阅读次数:271
HDU 2815 Mod Tree (扩展 Baby Step Giant Step )
Mod TreeTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 96 Accepted Submission(s): 38Problem Desc...
分类:其他好文   时间:2014-10-07 18:21:23    阅读次数:209
POJ 2417 Discrete Logging ( Baby step giant step )
Discrete LoggingTime Limit:5000MSMemory Limit:65536KTotal Submissions:3696Accepted:1727DescriptionGiven a prime P, 2 k^i^m * k^j = n (mod p ) -> ...
分类:其他好文   时间:2014-10-07 16:05:23    阅读次数:205
POJ 2417
高次同余方程。 BL == N (mod P)求解最小的L。由于数据范围很大,暴力不行这里用到baby_step,giant_step算法。意为先小步,后大步。令L=i*m+j (m=ceil(sqrt(p-1))),那么原式化为 B^(i*m)*B^j==N(MOD P)————》B^j===N*...
分类:其他好文   时间:2014-08-30 16:16:19    阅读次数:244
34条   上一页 1 2 3 4 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!