Problem Statement | |||||||||||||
NOTE: This problem statement contains superscripts that may not display properly if viewed outside of the applet.
It is known that the binary notation (radix 2) of any integer is at most 4 times as long as the corresponding decimal notation. In this problem, you will examine a similar property for radices other then 2. You are given an int radix and ints low and high. Calculate the ratio of the length of the radix-based notation to the length of the decimal notation for each integer between low and high, inclusive. Return the average of these ratios. | |||||||||||||
Definition | |||||||||||||
| |||||||||||||
Notes | |||||||||||||
- | Numbers in radix-based notation are represented using the digits from 0 to radix-1, inclusive (uppercase letters A, B, C, ... are used to represent "digits" 10, 11, 12, ...). The number anan-1...a1a0 in radix-based notation corresponds to the number an*radixn + an-1*radixn-1 + ... + a1*radix + a0 in decimal notation. For example, B7F is the 16-based notation of the decimal number 11 * 162 + 7 * 16 + 15 = 2943. | ||||||||||||
- | When calculating notation lengths, numbers must be represented with no extra leading zeros. | ||||||||||||
- | The returned value must have an absolute or relative error less than 1e-9. | ||||||||||||
Constraints | |||||||||||||
- | high will be between 1 and 1000000, inclusive. | ||||||||||||
- | low will be between 1 and high, inclusive. | ||||||||||||
- | radix will be between 2 and 16, inclusive. | ||||||||||||
Examples | |||||||||||||
0) | |||||||||||||
| |||||||||||||
1) | |||||||||||||
| |||||||||||||
2) | |||||||||||||
| |||||||||||||
3) | |||||||||||||
| |||||||||||||
4) | |||||||||||||
|