BSGS算法是meet in the middle思想的一种应用,参考Yveh的博客我学会了BSGS的模版和hash表模板,,, 现在才会hash是不是太弱了,,, #include<cmath> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; struct node{ static const int mo=100007; int a[100010],v…
POJ 2417 Discrete Logging Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 4860 Accepted: 2211 Description Given a prime P, 2 <= P < 231, an integer B, 2 <= B < P, and an integer N, 1 <= N < P, compute the discrete logarith…
求解 A^x ≡ B mod C C是质数 的最小非负整数解 证明:A^x ≡ A^(x%φ(C)) mod C A^(x%φ(C)) ≡ A^(x-k*φ(C)) ≡ (A^x)/ A^(k*φ(C)) ≡ A^x mod C 所以枚举的话,x只需要枚举[0,φ(c)-1] 若x在[0,φ(C)-1]范围内有解,则同余方程有解,否则无解 令m=ceil(sqrt(m)),x=i*m-j A^(i*m-j) ≡ B mod C A^(i*m) ≡ B* A^j mod C 将 B* A^j…