#Q165. 「一本通 5.3 例 1」Amount of Degrees
「一本通 5.3 例 1」Amount of Degrees
Description
Original source: NEERC 2000 Central Subregional, problem statement available at Ural 1057.
Find the number of integers in the given interval that satisfy the following condition: the number is exactly equal to the sum of distinct integer powers of . For example, given , , , , there are exactly three numbers that meet the condition:
$$\begin{align} 17&=2^4+2^0 \\ 18&=2^4+2^1 \\ 20&=2^4+2^2 \end{align} $$Input Format
The first line contains two integers and . The next two lines contain integers and .
Output Format
Output a single integer representing the count of numbers that satisfy the condition.
Sample 1
15 20
2
2
3
Data Range and Hint
For all data, , , .