#600. 「Nowcoder多校 2019 Day5」maximum clique 1
「Nowcoder多校 2019 Day5」maximum clique 1
当前没有测试数据。
题目描述
You are given a set S containing n distinct positive integers .
Please find a subset of S which has the maximum size while satisfying the following constraint:
The binary representations of any two numbers in this subset must have at least two different bits.
If there are multiple valid subsets, please output any one of them.
输入格式
The input contains only two lines.
The first line contains an integer N denoting the size of S. The second line contains N positive integers denoting the members of set S.
-
-
-
all are distinct
输出格式
You should output two lines.
The first line contains one integer m denoting the size of the subset you found.
The second line contains m positive integers denoting the member of this subset.
样例
样例输入 1
5
3 1 4 2 5
样例输出 1
3
4 1 2
样例解释 1
3 (112) and 1 (012) has only 1 different bit so they can not be in the set together. 4 (1002) and 1 (0012) has 2 different bits so they can be in the set together. Following unordered pairs are allowed to be in the set together: <1, 2>, <1, 4>, <2, 4>, <2, 5>, <3, 4>, <3, 5>. Thus the maximum set is of size 3 ({1, 2, 4}).