DWITE Online Computer Programming Contest, April 2010, Problem 2
Yet another "round to arbitrary sequence" question -- powers of 2. Given a non-negative integer, what is the closest integer that is also an integer power of 2? This one actually might have some potential application, as integer powers of 2 are represented by a single bit in a digital sequence -- numbers that are the easiest to work with in digital circuits, so we might want to approximate some numbers to work with "easier" numbers instead.
The input will contain 5 lines, integers .
The output will contain 5 lines, corresponding integers rounded to the closest integer power of 2. If there are two integers equally far away, then use the higher value for the answer.
The sequence starts as: .
0 1 2 3 5
1 1 2 4 4