P16138 Equation of Bits (popcount)

Description

Given a positive integer $a$, output a positive integer $n$ such that $a\times\operatorname{popcount}(n)=n$, where $\operatorname{popcount}$ denotes the number of $1$'s in the binary representation. If no such $n$ exists, output $-1$. If the answer is not unique, you may output any one. **You need to solve $T$ such problems.**

Input Format

The first line contains one positive integer $T$, representing the number of problems. Line $i+1\ (1\le i\le T)$ contains one positive integer $a$, representing the $i$-th problem.

Output Format

Output $T$ lines, where line $i\ (1\le i\le T)$ contains one integer representing the answer to the $i$-th problem.

Explanation/Hint

## Explanation of Samples For the $1$-st problem, $5\times\operatorname{popcount}(10)=5\times 2=10$. For the $2$-nd problem, $27\times\operatorname{popcount}(81)=27\times 3=81$. In addition, $108$ is also an answer. For the $3$-rd problem, it can be proved that no positive integer $n$ satisfies $26\times\operatorname{popcount}(n)=n$. ## Constraints For all testdata, it is guaranteed that: - $1\le T\le 10^5$; - $1\le a\le 10^{16}$. ::cute-table{tuack} |Test point|$a\le$|$T\le$|Special property| |:-:|:-:|:-:|:-:| |$1$|$10$|$10$|None| |$2$|$4000$|$1000$|Guaranteed to have a solution| |$3,4$|^|^|None| |$5$|$10^{16}$|$54$|$a$ is a power of $2$| |$6\sim 10$|^|$10^5$|None| Translated by QwenWork