All submissions for this problem are available.Saifullah Talukder is $22$ years old and yet he had no luck in his love life so far. He has lost all hope about this. Thinking that he will never have any love in his life he started to think about love between numbers. According to him two numbers are in love with each other if their bitwise-xor and sum are equal. For example: bitwise-xor of $160$ and $75$ is $235$ and their sum is also $235$. Hence $160$ and $75$ are in love with each other. On the other hand the bitwise-xor of $32$ and $63$ is $31$ but their sum is $95$. Hence $32$ and $63$ are not lovers. In this problem Saifullah will ask you $Q$ questions. In each question he will give you a number $X$. Your task is to find out the largest lover of $X$ not exceeding $X$ and the smallest lover of $X$ greater than $X$. If any of the answer doesn’t exist simply print $-1$. ###Input: The first line of input will contain a single integer $Q$ ($1 \leq Q \leq 10^5$). The number of questions. It will be followed by $Q$ lines each containing a single integer $X$ ($0 \leq X \leq 10^9$). ###Output: For each question, output in a single line the answer to the problem. Print the largest lover of $X$ not exceeding $X$ and the smallest lover of $X$ greater than $X$ separated by a single pace. ###Sample Input: $5$ $8 $ $36$ $1995$ $536870911 $ $1000000000 $ ###Sample Output: $7$ $16$ $27$ $64$ $52$ $2048$ $0$ $536870912$ $73741823$ $1073741824$
|Time Limit:||2 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, kotlin, TEXT, PYP3|
Fetching successful submissions
If you are still having problems, see a sample solution here.