106. Fast Power
Challenge1000 ms256 MBSolved by 0%
Read a and b and print a raised to the power b, modulo
1000000007.
The modulo keeps the answer small. The exponent does not.
Constraints - `0 ≤ a ≤ 1000000000` - `0 ≤ b ≤ 1000000000000000000`
Input
A single line containing two integers, separated by a space.
Output
Print one integer — a to the power b, taken modulo 1000000007.
Input2 10
Output1024
Noteis a small power with an exact answer
Input5 0
Output1
Notehas an exponent of zero, so the loop never runs and the answer is 1
Hints
Four rungs, in order. The last two open once you have submitted an attempt — a wrong one counts.
Hint 1Where to start
Hint 2The approachOpen hint 1 first — this one carries on from it.
Hint 3PseudocodeOpen hint 2 first — this one carries on from it.
Hint 4Full solutionOpen hint 3 first — this one carries on from it.