## DWITE '10 R4 #3 - Binary Weight

View as PDF

Points: 5
Time limit: 0.1s
Memory limit: 64M

Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig
##### 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 ().

#### Sample Input

3
4
10
7
8

#### Sample Output

5
8
12
11
16