3128 - AND of Two 3128 - AND of Two 3128 - AND of Two

Statistics Sub: 249 | AC: 66 | AC%: 26,51 | Score: 2,20
Created by José Carlos González Fernández
Added by jcfernandez (2015-02-25)
Limits
Total Time: 2000 MS |Memory: 62 MB | Output: 64 MB | Size: 14 KB
Enabled languages
Available in

Description

Nolberto learnt bitwise-operation recently. He got very fascinated about bitwise-operation for its wonderful uses. But his girlfriend is not sure of that he has enough skills to solve bitwise-operation problem. So, she decides to test his skills by giving a problem.

She gave N non-negative integers A1, A2,...AN, and asks him to find the pair of integers such that AND operation on that pair of integers is maximum.

AND is a bit-wise operation which is corresponding to & in C++ and Java.
Nolberto learnt bitwise-operation recently. He got very fascinated about bitwise-operation for its wonderful uses. But his girlfriend is not sure of that he has enough skills to solve bitwise-operation problem. So, she decides to test his skills by giving a problem.

She gave N non-negative integers A1, A2,...AN, and asks him to find the pair of integers such that AND operation on that pair of integers is maximum.

AND is a bit-wise operation which is corresponding to & in C++ and Java.
Nolberto learnt bitwise-operation recently. He got very fascinated about bitwise-operation for its wonderful uses. But his girlfriend is not sure of that he has enough skills to solve bitwise-operation problem. So, she decides to test his skills by giving a problem.

She gave N non-negative integers A1, A2,...AN, and asks him to find the pair of integers such that AND operation on that pair of integers is maximum.

AND is a bit-wise operation which is corresponding to & in C++ and Java.

Input specification

The first line of the input contains an integer 1 <= T <= 100 denoting the number of test cases.
The description of T test cases follows: The first line of the input contains a single integer 2 <= N <= 10^5. The ith line in the next N lines contains the 0<=Ai<=10^3. 
The first line of the input contains an integer 1 <= T <= 100 denoting the number of test cases.
The description of T test cases follows: The first line of the input contains a single integer 2 <= N <= 10^5. The ith line in the next N lines contains the 0<=Ai<=10^3. 
The first line of the input contains an integer 1 <= T <= 100 denoting the number of test cases.
The description of T test cases follows: The first line of the input contains a single integer 2 <= N <= 10^5. The ith line in the next N lines contains the 0<=Ai<=10^3. 

Output specification

Print a single integer which is the largest value of Ax AND Ay where 1 <= x < y <= N.
Print a single integer which is the largest value of Ax AND Ay where 1 <= x < y <= N.
The first line of the input contains an integer 1 <= T <= 100 denoting the number of test cases.
The description of T test cases follows: The first line of the input contains a single integer 2 <= N <= 10^5. The ith line in the next N lines contains the 0<=Ai<=10^3. 

Sample input

1
4
2
4
8
10

Sample output

8

Hint(s)

http://coj.uci.cu/24h/
http://coj.uci.cu/24h/
http://coj.uci.cu/24h/

Recommendation

We have carefully selected several similar problems: 3376 | 2769 | 1873 | 2441 | 2534 | 2141