In C/C++ how can I calculate (a^b)%m
where b
does not fit into 64 bits? In other words, is there a way of calculating the above value using b%m
instead of b
?
And is there any algorithm that can compute the above result in O(log(b))
time or O(log(b%m))
time?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…