问题 D: GCD VS XOR

内存限制:256 MB 时间限制:1 S
题面:Markdown 评测方式:Special Judge 上传者:
提交:8 通过:4

题目描述

Ben\_H has a positive integer $x$. He wants you to find another positive integer $y$, which is strictly less than $x$, so that the equation $gcd(x, y) = x \oplus y$ holds. Can you help him? where $\oplus$ is bitwise XOR operation (see notes for explanation).

输入格式

The first line contains a single integer $t (1 \leq t \leq 10^4)$ — the number of test cases. The only line of each test case contains a single integer $x (1\leq x \leq 10^{18})$.

输出格式

For each testcase, output a single positive integer $y$, if you find a feasible answer, or $-1$ otherwise.

输入样例 复制

2
15
1

输出样例 复制

10
-1

数据范围与提示

$gcd(x, y)$ represents the greatest common divisor of $x$ and $y$, such as $gcd(4, 6) = 2$. A bitwise XOR is a binary operation that takes two bit patterns of equal length and performs the logical exclusive OR operation on each pair of corresponding bits. The result in each position is $1$ if only one of the bits is $1$, but will be $0$ if both are $0$ or both are $1$.