Binary Palindromes
Medium
Execution time limit is 1 second
Runtime memory usage limit is 64 megabytes
Your task is to determine the smallest binary palindrome that is greater than or equal to a given number ( n ).A binary palindrome is a number that appears the same when read from left to right and right to left in the binary numeral system. For example, the numbers 5, 7, 9, and 21 are binary palindromes, whereas 4, 10, and 11 are not.
Input
The first line contains the integer ( n ).
Output
Output a single line with the smallest binary palindrome that is greater than or equal to ( n ).
Evaluation:
40% of the test cases will have ( n \leq 10^5 )
60% of the test cases will have ( n \leq 10^{18} )
Examples
Input #1
Answer #1
Input #2
Answer #2
Input #3
Answer #3
Submissions 420
Acceptance rate 15%