DWITE Online Computer Programming Contest, January 2011, Problem 3
The binary weight of a number is the amount of s in the number's binary representation. For example, in binary is , so the binary weight is . Given a decimal number, we want to find the next greater decimal number that has the same binary weight. In this case, () is such a number.
The input will contain 5 lines, integers .
The output will contain 5 lines, each corresponding to the next decimal number with the same binary weight as in the input.
Reminder: a binary representation of a number is the sum of powers of , where means that power is included, and means that it's not. So a binary is , which evaluates to ().
3 4 10 7 8
5 8 12 11 16