204. Power
Foundation1000 ms256 MBSolved by 0%
Print a raised to the power b.
Recursively, a^b is a times a^(b-1), and a^0 is 1 whatever a
is. That last fact is the base case.
The constraints keep the answer inside 64 bits, so you do not need modular
arithmetic here. You do need to notice that b can be 0.
Constraints - `1 ≤ a ≤ 15` - `0 ≤ b ≤ 15` - The answer fits in a signed 64-bit integer.
Input
A single line containing two integers a and b, separated by a space.
Output
Print one integer, the value of a raised to the power b.
Input2 10
Output1024
Noteis a power of two you can check
Input5 0
Output1
Noteis the base case, where anything to the power 0 is 1
Hint 1Approach
Hint 2Approach
Hint 3Pseudocode
Hint 4Full solution