| SBC Brazilian Phase Zero 2025 |
|---|
| Закончено |
Several quantum alternatives to traditional algorithms have been researched to solve a variety of problems. Using quantum logic gates, it is possible to gain performance in some specific types of tasks, leading to improvements, for example, in number factorization algorithms and data set searches.
Shor is working on a quantum algorithm for recognizing palindromes in binary sequences. To do this, he needs to generate a large number of examples, and he decided that he would need to know for a given positive integer $$$X$$$, what the largest integer $$$Y$$$ less than or equal to $$$X$$$ would be, whose binary representation is palindromic.
Shor has a lot of experience with quantum algorithms, but he is having difficulty creating a classical algorithm that solves this problem. Can you help?
The only line of input contains the integer $$$X$$$ ($$$1 \leq X \leq 10^{18}$$$).
Output a single line with the corresponding integer $$$Y$$$.
9945
9945
11
9
154
153
| Название |
|---|


