|
|||||||||||
N BitsHow many different integers between A and B (including A and B) have exactly N bits of 1 in the two's complement representation? That's the question to be answered in this problem. ExampleThe problem is pretty clear. For example, suppose A is 5, B is 14, and N is 2. If we look at the two's complement binary representation of the integers between 5 and 14 and identify those with exactly 2 one bits, we find that there are five such numbers (identified by the left-pointing arrows):
So the answer for this case would be 5. (All the high-order bits in these numbers are 0; they are not shown for clarity.) Input SpecificationThere will be multiple input cases to consider. For each case there will be a single input line containing A, B, and N. The input for the last case will be followed by a line containing three zeroes. A and B will each be in the range –2 147 483 648 to +2 147 483 647, and N will be in the range 1 to 32. Output SpecificationFor each input case, display the case number (1, 2, …) and the appropriate number. Display a blank line after the output for each case. The sample input and output illustrate the appropriate formats. Sample Input
Output for Sample Input
|
|||||||||||
University of Debrecen; Faculty of Informatics; v. 03/01/2019 |