Timeline
Timeline
2025-11-26
init
Math
Problem:
If we directly loopntimes, the time isO(n), it will time out. Use fast exponentiation:
Fast exponentiation is based on a fact:
If n is even:
If n is odd:
Each time n is halved, so the time complexity isO(log n)。
1 |
|

