Codeforces Global Round 1
C
Meaningless Operations
Codeforces
1500
原题
← BD →
翻译中…

Can the greatest common divisor and bitwise operations have anything in common? It is time to answer this question.

翻译中…

Suppose you are given a positive integer $a$. You want to choose some integer $b$ from $1$ to $a - 1$ inclusive in such a way that the greatest common divisor (GCD) of integers $a \oplus b$ and $a \ \gt \& \ \gt b$ is as large as possible. In other words, you'd like to compute the following function:

翻译中…

$$f(a) = \max_{0 \lt b \lt a}{gcd(a \oplus b, a \ \gt \& \ \gt b)}.$$

翻译中…

Here $\oplus$ denotes the bitwise XOR operation, and $\&$ denotes the bitwise AND operation.

翻译中…

The greatest common divisor of two integers $x$ and $y$ is the largest integer $g$ such that both $x$ and $y$ are divided by $g$ without remainder.

翻译中…

You are given $q$ integers $a_1, a_2, \ldots, a_q$. For each of these integers compute the largest possible value of the greatest common divisor (when $b$ is chosen optimally).

翻译中…

Input

翻译中…

The first line contains an integer $q$ ($1 \le q \le 10^3$) — the number of integers you need to compute the answer for.

翻译中…

After that $q$ integers are given, one per line: $a_1, a_2, \ldots, a_q$ ($2 \le a_i \le 2^{25} - 1$) — the integers you need to compute the answer for.

翻译中…

Output

翻译中…

For each integer, print the answer in the same order as the integers are given in input.

翻译中…

Note

翻译中…

For the first integer the optimal choice is $b = 1$, then $a \oplus b = 3$, $a \ \gt \& \ \gt b = 0$, and the greatest common divisor of $3$ and $0$ is $3$.

翻译中…

For the second integer one optimal choice is $b = 2$, then $a \oplus b = 1$, $a \ \gt \& \ \gt b = 2$, and the greatest common divisor of $1$ and $2$ is $1$.

翻译中…

For the third integer the optimal choice is $b = 2$, then $a \oplus b = 7$, $a \ \gt \& \ \gt b = 0$, and the greatest common divisor of $7$ and $0$ is $7$.

翻译中…

样例

Input #1
3
2
3
5
Output #1
3
1
7
InputCopy OutputCopy
题目信息
题号
1110C
时间限制
1 s
内存限制
256 MB
标签
构造
数学
数论

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。