算法原理:
Python代码:
1 def kuaiSuZhiShu(di, zhiShu, mod): 2 zhiShu2 = bin(zhiShu)[2:] 3 length = len(zhiShu2) 4 jieGuo = di**int(zhiShu2[0]) 5 for i in range(1, length): 6 jieGuo = jieGuo**2 % mod 7 jieGuo = jieGuo*di**int(zhiShu2[i]) % mod 8 return jieGuo 9 print(kuaiSuZhiShu(11, 23, 187))
原文地址:https://www.cnblogs.com/kexve/p/11622336.html
时间: 2024-12-11 15:57:03