Next K-Bit Number

Time Limit : 1 Second

Memory Limit : 128 MB

Submission: 619

Solved: 226

Description
     Our problem is to create a function: uint NextKBitNumber(uint), which given an unsigned integer X with K bits set, returns the immediately larger unsigned integer also with K bits set. For example, if X = 12 (base 10) = 1100(base 2), X has 2 bits set, then  the next number with 2 bits set(NextKBitNumber) is 17(base 10) = 10001(base 2).
Input
      The first line is the number of test cases,there are at most 1001 cases.

      Then each line is a case with an unsigned  number X.

      It is guaranteed that all answers are in unsigned 32-bit Integer.

Output
      For each cases, the first line is “Case #k:”, where k is the case index based 1.

      The second line is  the NextKBitNumber of X.
sample input
2
12
7
sample output
Case #1:
17
Case #2:
11
hint
source
Yang WANG
© 2015 HUST ACMICPC TEAM. All Right Reserved.