PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GL0000379. Các phép toán vô nghĩa (Meaningless Operations)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Các phép toán vô nghĩa (Meaningless Operations)
Meaningless Operations
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
For an integer , choose an integer such that to maximize
$$f(a)=\max_{1\le b<a}\gcd(a\oplus b,\ a\mathbin{\&}b).$$Here denotes bitwise XOR and denotes bitwise AND, acting on the unsigned binary representations. We use for .
There are independent values of . Output only the maximum value for each one; do not output the optimizing . Queries do not affect one another.
Input
The first line contains . Each of the next lines contains one integer .
Output
Print exactly lines; line contains .
Subtasks
-
Subtask 1 (20 points): , .
-
Subtask 2 (30 points): , .
-
Subtask 3 (50 points): , .
Examples
Example 1
Input
3
2
3
5
Output
3
1
7
Explanation
For , choose : XOR is , AND is , so GCD is . For , choose giving . For , choose : XOR is and AND is , so the maximum is .