##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
1 5
5
1 6
7
3 1 10 32
1 15 33
Given queries, each with a positive integer , find the smallest positive integer whose binary representation (without leading zeros) is a palindrome and is greater than or equal to .
A binary palindrome reads the same forwards and backwards. For example, , , and are binary palindromes, while and are not.
The binary representation of is , which reads the same forwards and backwards. So is already a binary palindrome. Answer: 5.
, not a palindrome. , which is a palindrome. Answer: 7.
Query 1: , already a palindrome. Answer: 1. Query 2: , not a palindrome. We check: (no), (no), ..., (yes, palindrome). Answer: 15. Query 3: , not a palindrome. , which is a palindrome. Answer: 33.