算法原理:
(我们老师PPT上的)




或者看另一位博主的文章:http://t.csdn.cn/dPG1G

Python算法实现:
from gmpy2 import invert #求逆元模块
# p,a,b=383,2,228
# n=191
#测试用例
print("a^x==b mod p\n求x=log a (b)\n")
p=int(input('输入p='))
a=int(input('输入a='))
b=int(input('输入b='))
n=int(input('输入阶数n='))
def fun_x(x):
#输入x[i]返回x[i+1]
if (x % 3 ==1):
x_next = x * b % p
elif(x %


4801

被折叠的 条评论
为什么被折叠?



