算法原理
Python代码
def kuaiSuZhiShu(di, zhiShu, mod):
zhiShu2 = bin(zhiShu)[2:]
length = len(zhiShu2)
jieGuo = di**int(zhiShu2[0])
for i in range(1, length):
jieGuo = jieGuo**2 % mod
jieGuo = jieGuo*di**int(zhiShu2[i]) % mod
return jieGuo
print(kuaiSuZhiShu(59, 26, 71))