Məsələlər
Not One Bit More
Not One Bit More
Start with an integer, \textbf{N_0}, which is greater than \textbf{0}. Let \textbf{N_1} be the number of ones in the binary representation of \textbf{N_0}. So, if \textbf{N_0} = \textbf{27}, \textbf{N_1} = \textbf{4}.
In general, let \textbf{N_i} be the number of ones in the binary representation of \textbf{N_\{i-1\}}. This sequence will always converge to one.
For any starting number, \textbf{N_0}, let \textbf{K}(\textbf{N_0}) be the minimum \textbf{i} such that \textbf{N_i} is one. For example, if \textbf{N_0} = \textbf{31}, then \textbf{N_0} = \textbf{5}, \textbf{N_\{1 \}}= \textbf{5}, \textbf{N_2} = \textbf{2}, \textbf{N_3} = \textbf{1}, so \textbf{K}(\textbf{31}) = \textbf{3}.
Given a range of consecutive numbers, and a value \textbf{X}, how many numbers in the range have a \textbf{K}(...) value equal to \textbf{X}?
\InputFile
There will be several test cases in the data file. Each test case will consist of three integers on a single line:
\textbf{LO HI X}
where \textbf{LO} and \textbf{HI} (\textbf{1} ≤ \textbf{LO} ≤ \textbf{HI} ≤ \textbf{10^18}) are the lower and upper limits of a range of integers, and \textbf{X} (\textbf{0} ≤ \textbf{X} ≤ \textbf{10}) is the target value for \textbf{K}(...).
The data file will end with a line with three \textbf{0}s.
\OutputFile
For each test case, output a line with a single integer, representing the number of integers in the range from \textbf{LO} to \textbf{HI} (inclusive) which have a \textbf{K}(...) value equal to \textbf{X} in the input.
Giriş verilənləri #1
31 31 3 31 31 1 27 31 1 27 31 2 1 4 1 1023 1025 1 1023 1025 2 0 0 0
Çıxış verilənləri #1
1 0 0 3 2 1 1