Given three integers l, r, and k, return the number of integers in the inclusive range [[[l, r]]] that can be represented as nkn^knk for some integer n≥0n \geq 0n≥0.
l
r
k
Constraints:
0≤0 \leq0≤ l ≤\leq≤ r ≤109\leq 10^9≤109
1≤1 \leq1≤ k ≤30\leq 30≤30
Now, let’s take a moment to make sure you’ve correctly understood the problem. The quiz below helps you check if you’re solving the correct problem:
Count K-th Roots in a Range
For the input l = 0, r = 0, and k = 1, how many integers in the range can be represented as n1n^1n1 for some integer n≥0n \geq 0n≥0?
l = 0
r = 0
k = 1
000
222
111
101010
We have a game for you to play. Rearrange the logical building blocks to develop a clearer understanding of how to solve this problem.
Implement your solution in the following coding playground.