Problem Statement | |||||||||||||
Consider a function randomInt(integer N) that takes an integer N and returns an integer uniformly at random in the range 0 to N-1. If that function is nested, as in randomInt(randomInt(N)), the probability distribution changes, and some numbers are more likely than others. Given an int nestings defining the number of times the function is nested (1 indicates randomInt(N), 2 indicates randomInt(randomInt(N)), and so on), an int N and an int target, return the probability that the result of nestings nested calls to randomInt with the parameter N will result in target. | |||||||||||||
Definition | |||||||||||||
| |||||||||||||
Notes | |||||||||||||
- | Calling randomInt(0) causes an error to occur, and hence can never cause an outcome of target. | ||||||||||||
- | Your return must have a relative or absolute error less than 1E-9. | ||||||||||||
Constraints | |||||||||||||
- | N will be between 1 and 1000, inclusive. | ||||||||||||
- | nestings will be between 1 and 10, inclusive. | ||||||||||||
- | target will be between 0 and N-nestings, inclusive. | ||||||||||||
Examples | |||||||||||||
0) | |||||||||||||
| |||||||||||||
1) | |||||||||||||
| |||||||||||||
2) | |||||||||||||
|